Delay in Plotting Next Overlaid Plot When Animating 2D Plot
Show older comments
I have a 10 line plots that are overlaid, and I want to animate plotting each of these plots--one after the other. So I do need hold on, or some form of method to keep the previous plot as the new plot is being plotted.
The only problem I am facing is that after one plot has completed plot, before the next iteration, it takes a significant amount of time to start the next plot.
This time adds up when I have multiple overlaid plots (it compounds too).
Below I have shared my code, and a snippet of the data I am using to plot. Please point out how I can fix this
clc;clear;close all;load('data.mat');
fv=data{1};rv=data{2};
cmap = jet(5); figure;hold on
% v = VideoWriter('example', 'MPEG-4');
% open(v);
for i = 1:3
f=fv(:,i);r=rv(:,i);
color = cmap(i,:);
tic
for ii=1:length(f)
plot(f(1:ii),r(1:ii),'LineWidth',2,'Color',color);pause(0.005)
end
toc;disp('Next Plot')
end
% close(v);
Accepted Answer
More Answers (0)
Categories
Find more on Animation 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!