Just to explain what I am facing, I have the following code.
ind=(1:10);
A=[sin(ind);cos(ind);tan(ind);sec(ind)]';
plot(ind,A(:,1),ind,A(:,2),ind,A(:,3),ind,A(:,4));
the result looks like this:
Now, in my real program, the matrix A gets updated every few seconds with new rows. And I want to update the graph dynamically as soon as I get a new row. After some googling I realized that I have to use drawnow, but not sure how.
I have the following code as of now.
B=A(1,:);
h = plot(B,'YDataSource','B');
for k = 1:size(A,1)
B=A(1:k,:);
refreshdata(h,'caller')
drawnow
pause(.25)
end
But I get the following error on this:
Error using refreshdata (line 70) Could not refresh YData from 'B'.
Error in test (line 9) refreshdata(h,'caller')
Please help.