Changing equation with loop
2 views (last 30 days)
Show older comments
Pretty much, I need to plot x Vs. Pratio
But I need to use
Me to equal 1 when Me>=1
and for anything else
need Me = sqrt(2./(gamma-1).*((nPratio.^((gamma-1)./gamma))-1));
then plot X in terms of both Me as they change
Im really bad a MATLAB so sorry if this does not make sense
P0 = 500000;
Pb = linspace(0,500000,100);
R = 287;
gamma = 1.4;
z = -((gamma+1)/(2*(gamma-1)));
Pratio = Pb/P0;
nPratio = 1./Pratio;
Me = sqrt(2./(gamma-1).*((nPratio.^((gamma-1)./gamma))-1));
for x = (P0.*sqrt(gamma/R).*Me.*(1+((gamma-1)/2).*Me.^2).^z)
if Me >=1
x = P0.*sqrt(gamma/R).*(1+((gamma-1)/2)).^z;
else
x = (P0.*sqrt(gamma/R).*Me.*(1+((gamma-1)/2).*Me.^2).^z);
end
figure(1)
plot(Pratio,x1)
xlabel('Pb/P0');ylabel('Msqrt(To)/Ae')
end
0 Comments
Answers (1)
darova
on 22 Feb 2020
Use this
Me = sqrt(2./(gamma-1).*((nPratio.^((gamma-1)./gamma))-1));
ind = Me < 1;
x = (P0.*sqrt(gamma/R).*Me.*(1+((gamma-1)/2).*Me.^2).^z)
x(ind) = P0.*sqrt(gamma/R).*(1+((gamma-1)/2)).^z;
figure(1)
plot(x,Pratio)
0 Comments
See Also
Categories
Find more on Run Unit Tests in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!