Changing equation with loop

1 vue (au cours des 30 derniers jours)
daniel Picasso
daniel Picasso le 22 Fév 2020
Réponse apportée : darova le 22 Fév 2020
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

Réponses (1)

darova
darova le 22 Fév 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)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by