Serial Communication With Matlab Using Timer Functions

I'm trying to setup serial communication between Matlab and an Arduino. As a test I have a logical input to the Arduino (it can be either 0 or 1). I then want to pass the value of the input to Matlab and display it. Here's the Arduino code I have:

void setup() {
  Serial.begin(9600);
  pinMode(5, INPUT);
}

void loop() {
  
  
  int NPleft = digitalRead(5);
  Serial.println(NPleft);
  
}

Here's the Matlab code:

delete(instrfindall)
clear all
s1 = serial('COM3');    % define serial port
s1.TimerPeriod=1;
s1.Terminator='LF';
fopen(s1);
s1.BaudRate=9600;               % define baud rate
s1.TimerFcn=@(x,y)disp(char(fscanf(s1)));

I want Matlab to check the value being sent to it serially every second. What ends up happening is it just displays the first value it gets over and over again. So if the first value of the input is 1, it keeps displaying 1 over and over again regardless if the input goes back to 0. What am I doing wrong?

How big is the serial buffer on the Matlab side? Your Arduino code is streaming millions of bytes per second to the serial port. Add a delay(1000) after the Serial.print(), to send data just once per second.