Why does the PRINT command take so long with a scatter plot in MATLAB 7.5 (R2007b)?
Show older comments
The PRINT command with the -djpeg flag takes a very long time to run. I have created a scatter plot with a large amount of data. I would like to export it to a jpeg but the print command takes a long time or freezes MATLAB completely.
Reproduction steps:
NumPoints=2000
x=[0:1:NumPoints];
sinx=0.25.*x.*sin(x);
cosx=0.25.*x.*cos(x);
scatter(sinx,cosx,'.');
tic
print -djpeg testspiral.jpg;
toc
Gives:
Elapsed time is 33.067874 seconds.
Compare that result with this one:
%
phmin=deg2rad(70);
phmax=deg2rad(50);
thmin=0;
thmax=2*pi;
NumPoints=200000
ph = phmin+(phmax-phmin).*rand(NumPoints,1);
th = thmin+(thmax-thmin).*rand(NumPoints,1);
[x y]=pol2cart(th,ph);
scatter(x,y,'.');
tic
print -djpeg myrand_cut.jpg
toc
which gives
Elapsed time is 13.166636 seconds.
Notice that the second example runs in less time with a data set that is 100 times larger.
For some reason the PRINT command has a particularly hard time with this type of cyclical data.
Accepted Answer
More Answers (0)
Categories
Find more on Scatter 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!