Solving an equation help

1 次查看(过去 30 天)
So i have an equation shown as 'eqn' shown below, I am trying to solve for M but for some reason my code isnt running and im not sure why, any help would be appreciated
a = 1.4;
x = -0.5:0.1:0.5;
b = 0.153 + x.^2;
A1 = 0.153;
F2 = (b./A1);
eqn = F2 == ((a+1)./2).^((-a+1)/2.*(a-1)).*(((1+((a-1)./2)*M.^2).^((a+1)/2.*(a-1)))./M);
s = solve(eqn);
  3 个评论
Cizzxr
Cizzxr 2021-3-17
编辑:Walter Roberson 2021-3-17
M is the Mach Number which needs to be solved, Ive used the equation in red which has a red rectangle around it on this page https://www.grc.nasa.gov/www/k-12/airplane/astar.html
M is the unknown and so basically, the value of F2 will change depending on what value of x in the array created is inputted.
So for example, a value of x=0 in the array will result in 'b' being 0.153,
which means the ratio of F2 is 0.153/0.153 which is 1. Thus F2 is equal to 1
and then the only unknown in my equation is M which im asking matlab to rearange to make M the subject and possibly plot a graph
of results
Cizzxr
Cizzxr 2021-3-17
I mean it could attempt to rearange the equation for M but im bound to make a mistake somewhere hence why i wanted to see if matlab would do it for me

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2021-3-17
a = 1.4;
x = -0.5:0.1:0.5;
b = 0.153 + x.^2;
A1 = 0.153;
F2 = (b./A1);
syms M real
assume(M>0)
eqn = F2 == ((a+1)./2).^((-a+1)/2.*(a-1)).*(((1+((a-1)./2)*M.^2).^((a+1)/2.*(a-1)))./M);
s = arrayfun(@vpasolve, eqn);
vpa(s,5)
ans = 

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by