Using vpasolve in a for loop ERROR

2 次查看(过去 30 天)
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

回答(1 个)

Yasasvi Harish Kumar
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

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by