![scatter plot matlab scatter plot matlab](https://www.mathworks.com/help/examples/graphics/win64/CreateScatterPlotMatrixwithTwoMatrixInputsExample_01.png)
Furthermore, you're calling several functions often instead of just once and incur thus calls from the function overhead. The main difference between the time required to plot in a loop versus plotting in one go is that you add the handle to the plot as a child to the axes (have a look at the output of get(gca,'Children')), and you're thus growing a complicated array inside a loop, which we all know to be slow. If scatter3 was compiled as well, the speed difference would be small. The main difference between the time required to run scatter3 and plot3 comes from the fact that plot3 is compiled, while scatter3 is interpreted (as you'll see when you edit the functions). Thanks to advice from Ben Voigt (see answers), I have included drawnow commands in the timing - but this has made little difference to the times. What is it that MATLAB does behind the scenes in the 'longer' routines to take so long? What are the advantages and disadvantages of using each method? Individual plotting using plot3: > tic hold on Individual plotting using scatter3: > tic hold on īulk plotting using plot3: > tic plot3(X, Y, Z, 'o') drawnow toc I closed all figures and cleared the workspace between each run to try to ensure fairness.īulk plotting using scatter3: > tic scatter3(X, Y, Z) drawnow toc I then used one of four different methods to plot this, to create a plot like so:
![scatter plot matlab scatter plot matlab](http://www.mbfys.ru.nl/~robvdw/CNP04/LAB_ASSIGMENTS/LAB05_CN05/MATLAB2007b/stats/html/mvplotdemo_01.png)
![scatter plot matlab scatter plot matlab](https://www.mathworks.com/help/examples/matlabmobile/win64/Scatter3DPlotExample_01.png)
I generate 10000 points in 3D space: X = rand(10000, 1) This is about how MATLAB can take very different times to plot the same thing - and why.