MATLAB: Plotting in a for loop

aerodynamicsvortexwhile loop

Hello, I am trying to plot in a while loop and I am having trouble figuring out how to set this up. I am calling a function that I have written to vary the x component of the vector from -20 to 20 in increments of 5. The code for the function and the file I am using are shown below.
Code:
x1=-1;
y1=0;
z1=0;
x2=1;
y2=0;
z2=0;
x=-25;
y=5;
z=0;
while x<20
x=x+5
vortexsegment(x1,y1,z1,x2,y2,z2,x,y,z);
end
Function:
function[Vx,Vy,Vz]=vortexsegment(x1,y1,z1,x2,y2,z2,x,y,z);
S=[x1,y1,z1]; % defining points for start
E=[x2,y2,z2]; % defining points for end
R=[x,y,z]; % defining points for point of interst
A=S-R; % Finding vector a
B=E-R; % Finding vector b
Z1=cross(A,B);
Z2=dot(A,B);
MagA=norm(A);
MagB=norm(B);
q=(Z1./(dot(Z1,Z1))).*(MagA+MagB).*(1-(Z2./(MagA.*MagB)));
V=(1./(4.*3.14)).*q
Vx=V(1,1)
Vy=V(1,2)
Vz=V(1,3)
Thanks

Best Answer

Did you try to plot Vx?
while x < 20
x=x+5
[Vx, Vy, Vz] = vortexsegment(x1,y1,z1,x2,y2,z2,x,y,z);
plot(Vx, 'b-', 'LineWidth', 3);
grid on;
drawnow;
end
Related Question