Why does it take MATLAB a long time to plot 150x1800 data?

I have the following data in my workspace:
X: 1x1800 double
Y: 150x1800 double
Why does it take a long time for me to plot this:
>> figure; hold on
>> for n=1:150
>> plot(X,Y);
>> hold on
>> end
Furthermore, MATLAB will freeze when I try to interact with the figure that is generated

 Accepted Answer

You might have accidentally plot your entire data 150 times.
(i.e. notice that you are plotting 150x in a for-loop of the same 150x1800 data points)
Therefore, this would significantly use more memory and, unsurprisingly, reduce graphic performance.
Removing the for-loop from your script would achieve the same figure with less figure creation time, less memory usage and improved interactivity performance:
>> figure
>> plot(X,Y);

More Answers (0)

Categories

Find more on Graphics Objects in Help Center and File Exchange

Products

Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!