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!

Translated by