how to plot for loop using concatenation to increase performance

I have the following for loop to plot vectors from a M by 3 matrix of points, known as A
for i=1:length(A)-512
plot3([A(i,1) A(i+512,1)],[A(i,2) A(i+512,2)],[A(i,3) A(i+512,3)],'-','MarkerSize',10)
hold on
end
such that each point is connected to the one 512 points after it. (sets of 512 points form 2D cross sections, and I'm connecting each cross section to the next)
However as length(A) in my dataset is around 20e3, the plot takes a while to generate, and the performance is poor when rotating.
Is there such a way to plot this in a more efficient manner using data concatenation or other methods?

답변 (1개)

darova
darova 2020년 4월 8일
Try to plot all together at once
n = size(A,1);
fv.vertices = A;
fv.faces = [1:n-512; 512+1:n]';
patch(fv)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

릴리스

R2018a

질문:

2020년 4월 8일

답변:

2020년 4월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by