2 views (last 30 days)

How can i change the variables X and Y values to a range of values in the code below? Its already in a loop and i used "hold on" to keep the plots previosly so the results are combined in one graph. Thanks in advance. In the code below i used one value for X and one value for Y, but i'd like to use the Y value range that i commented in the code.

clear all

clc

Vinf=100; % Input Vinf

a=deg2rad(15); % Input Alpha in degrees

N=100; % Number of Free Vortexes

c=1; % Length of chord c

X=-2*c;

% Y=linspace(-.7*c,0.1*c,20);

Y=-.7*c;

DeltaT=4e-8;

k=nonzeros(0:c/N:1);

for i=1:length(k)

s(i)=k(i); % si

s1=k(i)-(c/N); % si-1

% s2 is the center of free vortex i

s2=(s(i)+s1)*0.5;

ai=(s2*cos(a));

bi=((-s2)*sin(a));

Thetai=acos(1-2*s(i)); % θi

Thetai_1=acos(1-2*s1); % θi-1

G1(i)=(a*Vinf)*(Thetai-Thetai_1);

G2(i)=(2*a*Vinf)*[(sqrt(s(i)-s(i).^2))-(sqrt(s1-s1.^2))];

% Stength Gi of free vortex "i"

G(i)=G1(i)+G2(i);

u(i)=(G(i)/(2*pi))*((Y-bi)/((X-ai)^2+(Y-bi)^2));

v(i)=((-G(i))/(2*pi))*((X-ai)/((X-ai)^2+(Y-bi)^2));

end

UDT=u*DeltaT;

VDT=v*DeltaT;

DD=X+UDT;

D2=Y+VDT;

plot(DD, D2,'-or')

hold on

VBBV
on 23 Nov 2020

X=linspace(-2*c,1*c,20); % define X vector similar to Y but of same number of divisions i.e. 20

Y=linspace(-.7*c,0.1*c,20);

%Y=-.7*c;

DeltaT=4e-8;

k=nonzeros(0:c/N:1);

for jj = 1:length(X) % use another for loop for vectors X, Y

for i=1:length(k)

s(i)=k(i); % si

s1=k(i)-(c/N); % si-1

% s2 is the center of free vortex i

s2=(s(i)+s1)*0.5;

ai=(s2*cos(a));

bi=((-s2)*sin(a));

Thetai=acos(1-2*s(i)); % θi

Thetai_1=acos(1-2*s1); % θi-1

G1(i)=(a*Vinf)*(Thetai-Thetai_1);

G2(i)=(2*a*Vinf)*[(sqrt(s(i)-s(i).^2))-(sqrt(s1-s1.^2))];

% Stength Gi of free vortex "i"

G(i)=G1(i)+G2(i);

u(i,jj)=(G(i)/(2*pi))*((Y(jj)-bi)/((X(jj)-ai)^2+(Y(jj)-bi)^2)); % use the loop index where X & Y occurs

v(i,jj)=((-G(i))/(2*pi))*((X(jj)-ai)/((X(jj)-ai)^2+(Y(jj)-bi)^2));

end

end

Define the X vector similar to Y vector as you did, Add another for loop and use its index where X and Y vectors occurs

Rik
on 23 Nov 2020

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

Start Hunting!
## 0 Comments

Sign in to comment.