I am trying to simulate a real time plot in MATLAB in order to display an ECG signal. I am trying to test my idea with a small data set. I have created a matrix called Y containing values from 0 to 25*pi, and wish to plot sin(Y), with each data point being plotted as if it is in real time. This is the code I have written:
Y= [0:0.1:25*pi];
X = sin(Y);
[a,b] = size(Y);
for i = 1:b
hold on;
line(i,X(i));
drawnow;
pause(0.01);
end
This works well and the resulting graph moves as in "real time", however due to the discrete nature of the data set it plots single points instead of a smooth line. I was wondering if there is a way to convert the current graph output into something resembling a smooth line plot? Thank you in advance for any help on this issue.
try doing
plot(1:i,X(1:i));
instead of
line(i,X(i));
Edit: You wouldn't need to do hold on; with this method either.