Changing equation with loop

2 visualizaciones (últimos 30 días)
daniel Picasso
daniel Picasso el 22 de Feb. de 2020
Respondida: darova el 22 de Feb. de 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

Respuestas (1)

darova
darova el 22 de Feb. de 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)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by