Using vpasolve in a for loop ERROR

1 visualización (últimos 30 días)
Yoslin Herrera
Yoslin Herrera el 28 de Mzo. de 2019
Comentada: madhan ravi el 28 de Mzo. de 2019
I am trying to solve for the variable M given the values of v2. V2 is a 1x100 and I am looking for the value of M given each one of these V2. I tried implementing a for loop but I ended up with a 1x1 M instead of a 1x100.
syms M
M1=1.5;
gamma=1.4;
alpha=linspace(0,13); %theta max is 13 degrees
%must find M using Prantl-meyer expansion
v1=sqrt((gamma+1)/(gamma-1))*atan(sqrt((.4/2.4)*(M1^2-1)))-atan(sqrt(M1^2-1));
v1=v1*180/pi;
v2=v1+alpha;
for i =length(v2)
v2(i)=v1+alpha(i);
PM=(sqrt((gamma+1)/(gamma-1))*atan(sqrt(((gamma-1)/(gamma+1))*((M^2)-1)))-atan(sqrt((M^2)-1)))*180/pi==v2(i);
solM(i)=vpasolve(PM,M);
end

Respuestas (1)

Yasasvi Harish Kumar
Yasasvi Harish Kumar el 28 de Mzo. de 2019
Hi,
You have an error in your for loop definition and in using vpasolve. I think this should solve it.
syms M
gamma=1.4;
alpha=linspace(0,13); %theta max is 13 degrees
%must find M using Prantl-meyer expansion
v1=sqrt((gamma+1)/(gamma-1))*atan(sqrt((.4/2.4)*(M1^2-1)))-atan(sqrt(M1^2-1));
v1=v1*180/pi;
v2=v1+alpha;
for i =1:length(v2)
v2(i)=v1+alpha(i);
PM=(sqrt((gamma+1)/(gamma-1))*atan(sqrt(((gamma-1)/(gamma+1))*((M^2)-1)))-atan(sqrt((M^2)-1)))*180/pi==v2(i);
solM(i)=vpasolve(PM,M);
end
M = 1.5;
solution = eval(solM);
Regards

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by