Plot different functions in the same graph?
2 views (last 30 days)
Show older comments
Davide Cardi
on 18 Mar 2019
Edited: Davide Cardi
on 18 Mar 2019
Hi,
I would like to plot three function . Is there a way I can fix two of them (in the background) and make the other change every 1 second (for example)?
I mean, if I use "hold on" every second one graphic is added and if I don't use it the ones in the background get delete; I would like to change only one of them.
How should I do?
0 Comments
Accepted Answer
Walter Roberson
on 18 Mar 2019
plot first function
hold on
plot second function
h3 = plot third function
for t = 1 : whatever
calculate new X and Y to plot
set(h3, 'XData', new_X, 'YData', new_Y);
drawnow();
pause(time_interval_goes_here)
end
That is, record the returned handle of the plot you want to change, and inside the loop update the properties of that handle instead of making a new plotting call.
0 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Performance 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!