フィルターのクリア

Using vpasolve in a for loop ERROR

3 ビュー (過去 30 日間)
Yoslin Herrera
Yoslin Herrera 2019 年 3 月 28 日
コメント済み: madhan ravi 2019 年 3 月 28 日
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
Yasasvi Harish Kumar 2019 年 3 月 28 日
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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by