How to plot plot multiple vectors from a for loop ?
이전 댓글 표시
Hello everybody,
Here is my code, I am trying to plot, for each point of y variable (21 points) the corrsponding vector (each vector is made of the (0;0) coordinate point and the (y;z) coordinate).
Based on for loop structure I computed the (y;z) values for each y value, made a variable XY containing all the vectors that need to be plotted on the same figure. I struggle about the plotting, could you help me about this please ?
The idea is to have as final look a kind of a chinese fan you know :)
PFL = 25.4;
y = -20 : 2 : 20;
for i = 1 : length(y)
z(i) = sqrt((4 * PFL * y(i))) + (4 * PFL^2);
XY(i,:) = [y(i); z(i)]; % the formula for the vector coordinates (xb-xa; yb-ya) with a(0;0)
A = XY'; % swap rows and columns to use plotv()
for j = 1 : length(z)
plotv(A(:,j));
end
end
Thank you very much !
댓글 수: 1
Do you really mean plotv() from the deep leraning toolbox, or plot()?
The data have an imaginary part due to the square root of negative numbers. How do you want to display this?
plot() clears the axes before drawing. Avoid this by collecting the lines:
% Before the loop:
axes('NextPlot', 'add'); % Equivalent to: hold on
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!