Question about plotting a long series of lines
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Brian
am 12 Nov. 2013
Kommentiert: Doug Hull
am 12 Nov. 2013
Hello, thanks for reading this,
I want to plot a series of lines, which can range from 10 or so lines to thousands.
The total network is a binary tree, but not every line bifurcates. What I do at the moment is use a for loop, and plot every line separately, but that can take a large amount of time, and it doesn't help when I need to replot the tree in repetition. I was wondering, is there an easy way to vectorize this?
My data is the following: I have a point matrix (a N by 3 matrix, where I have n points, with columns x y and z coordinates), and a face matrix (a M by 2 matrix, where I have M faces, with point indexes 1 and 2). An example can be the following:
pointMx = [0 0 0; 0 5 0; 0 10 5; 0 10 0];
faceMx = [1 4; 4 2; 4 3];
So I have a total of three lines, with one bifurcating into two segments. I can plot this by looping over the number of rows in faceMx and plotting each line individually, but that can take time. Is there a way to vectorize the plotting of these lines?
Thanks for your help!
0 Kommentare
Akzeptierte Antwort
Doug Hull
am 12 Nov. 2013
>> clf; tic; for i = 1:10000; h(i) = line(rand(1,2), rand(1,2)); end; toc Elapsed time is 0.933154 seconds.
I respect the idea of limiting your overhead by reducing the number of line objects created. However, 0.9 second to make this graph. Is it really worth your effort to make this more efficient?
2 Kommentare
Doug Hull
am 12 Nov. 2013
You were likely making 10000, 3-d lines with the heavyweight plot3 command, rather than the much faster primitive. The overhead of a higher level command like plot3 is no big deal unless you are doing it 10k times...
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!