Problem with refreshing linked plot data
10 views (last 30 days)
Show older comments
The code sample I have below links data to a plot, and then starts modifying the data. The problem is that the plot never refreshes during the for loop. The linked plot only refreshes after the program is done.
Calling refreshdata in the for loop is not an option, because it takes too long and breaks the flow of the program. Any ideas on what I could do/try? I need for the plot to update every few seconds without breaking program flow.
clear all
close all
t = [0];
y = [0];
figure
h = plot(t,y);
set(h,'XDataSource','t');
set(h,'YDataSource','y');
linkdata on
for i = 1:50
t(i) = i;
y(i) = sin(i)
% refreshdata
pause(.1)
end
0 Comments
Accepted Answer
Walter Roberson
on 20 Jul 2011
clear all
close all
t = [0];
y = [0];
figure
h = plot(t,y);
for i = 1:50
t(i) = i;
y(i) = sin(i)
set(h, 'XData', t, 'YData', y);
pause(.1)
end
0 Comments
More Answers (0)
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!