Performance difference for plotting direction?
1 次查看(过去 30 天)
显示 更早的评论
I found a very odd behavior that I'd like some help on. When plotting large vectors in matlab, there appears to be a MAJOR performance hit when plotting vectors whose elements contain many decimal places in x vs. y. It appears to be much faster to plot these vectors in x than y.
Here is the minimally functional code.
elems = 1e7; %Define the number of elements
a = (1:elems); %Large generic vector with no decimals
b = rand(1,elems); %Large generic vector of the same length with many decimals
%First with a plotted as x and b plotted as y data
figure; tic; plot(a,b);drawnow;toc %Elapsed time is 1.202868 seconds.
figure; tic; plot(a,b);drawnow;toc %Elapsed time is 1.140523 seconds.
figure; tic; plot(a,b);drawnow;toc %Elapsed time is 1.105982 seconds.
%Now with b plotted as x and a plotted as y data
figure; tic; plot(b,a);drawnow;toc %Elapsed time is 4.654778 seconds.
figure; tic; plot(b,a);drawnow;toc %Elapsed time is 5.054447 seconds.
figure; tic; plot(b,a);drawnow;toc %Elapsed time is 4.788214 seconds.
I am not sure what is going on here, but my program (from which this example code was simplifed) started crashing when I tried to swap x and y data.
Any help would be appreciated. Even an explanation would be nice, as I don't this this is going to be resolvable.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!