Plotting real time data using MATLAB & Arduino

hi ,I can’t draw a graph in real time. I use a code but does 't work well :confused:

I use a potentiometer connected to the Arduino

code in arduino :

#define ADC1 A0  // Analog input pin 


void setup() 
{
 // initialize serial communications at 115200 bps:
 Serial.begin(115200); 
}

void loop() 
{
 Serial.println(analogRead(ADC1)); 
 delay(100); 

}

code in matlab :

clc;
clear all;
comport = serial('COM9', 'BaudRate', 115200); % setup comport
fopen(comport);  % Open comport
x=0;
while(x<100)
x=x+1;
y1(x)=fscanf(comport, '%d'); % receive ADC1

drawnow; 
pause(0.1);
plot(y1,'r-','linewidth',3)
grid on;
hold on;

title('  real time  ');
xlabel('Time in seconds');
ylabel('Digital Value');
end
fclose(comport); % Close comport
delete(comport); % Clear comport

can you give me a new code or help me to improve this code please
thank’s

I use a code but does 't work well

The code does something. What does it actually do? How does that differ from what you want?

I mean : when I change in my potentiometer the graph does not change and sometimes changing but very slowly :(

if you have anther code please give me Thank you

I mean : when I change in my potentiometer the graph does not change and sometimes changing but very slowly

Open the Serial Monitor, instead of Matlab. Do you see expected results?

Which end is the problem on?