I know all of the values of the equation shown apart from M. How do I go about finding it?
Cp = -6521
gamma = 1.4

 採用された回答

Star Strider
Star Strider 2021 年 4 月 15 日

0 投票

I ahve no idea what ‘Cp’ does here.
Otherwise:
gamma = 1.4;
prat = @(Me,gamma) ((1+(gamma-1)/2.*Me.^2).^(gamma/(gamma-1))) ./ (2*gamma/(gamma+1).*Me.^2 - (gamma-1)/(gamma+1));
Me = fsolve(@(Me)prat(Me,gamma), 10);
produces:
Me =
1.4832
.

10 件のコメント

Karl Zammit
Karl Zammit 2021 年 4 月 15 日
Thank you. Pardon my ignorance, but what does the 10 stand for?
Star Strider
Star Strider 2021 年 4 月 15 日
As always, my pleasure!
No worries! Every nonllinear optimisation function needs an initial estimate for every parameter it is to solve for. I randomly chose 10 here for that initial estimate.
See the documentation on fsolve for more information on it.
Karl Zammit
Karl Zammit 2021 年 4 月 15 日
Also the output is meant to be between 1 and 0. This does not change for different values of pressure ratio. Pressure ratio should be = -0.6521.
This pops up in the comand window - "
No solution found.
fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
value of the function tolerance."
Star Strider
Star Strider 2021 年 4 月 15 日
I have no idea how ‘Cp’ enters into this, since that was not stated, it is not part of the expression, and the posted value is times the intended value. I used the information originally provided.
With appropriate information, perhaps a solution is possible.
Karl Zammit
Karl Zammit 2021 年 4 月 16 日
Essentially, I need to find the value of M.
Star Strider
Star Strider 2021 年 4 月 16 日
I let the Symbolic Math Toolbox work with this:
syms Me
gamma = sym(1.4);
Cp = sym(-0.6521);
Eqn = Cp == ((1+(((gamma-1)/2).*Me.^2)).^(gamma/(gamma-1))) ./ ((2*gamma/(gamma+1)).*Me.^2 - (gamma-1)/(gamma+1)) ;
Me = solve(Eqn)
Me_vpa = vpa(Me)
abs_Me_vpa = abs(Me_vpa)
to get:
Me_vpa =
0.81165777828426109075260040547338i
1.1975001390442034303327301058217 + 0.99618983123429503559085894760276i
1.1975001390442034303327301058217 - 0.99618983123429503559085894760276i
1.6759020637684055112009161261056 + 2.6390184872797899437928880153373i
1.6759020637684055112009161261056 - 2.6390184872797899437928880153373i
-0.81165777828426109075260040547338i
- 1.1975001390442034303327301058217 - 0.99618983123429503559085894760276i
- 1.1975001390442034303327301058217 + 0.99618983123429503559085894760276i
- 1.6759020637684055112009161261056 - 2.6390184872797899437928880153373i
- 1.6759020637684055112009161261056 + 2.6390184872797899437928880153373i
abs_Me_vpa =
0.81165777828426109075260040547338
1.5576908431603171537631560287157
1.5576908431603171537631560287157
3.1261903818462034878433853976319
3.1261903818462034878433853976319
0.81165777828426109075260040547338
1.5576908431603171537631560287157
1.5576908431603171537631560287157
3.1261903818462034878433853976319
3.1261903818462034878433853976319
I checked the code, and it appears to do what the code in the image does.
The LaTeX version is:
that with the numeric substitutions is:
so it appears to be coded correctly.
Karl Zammit
Karl Zammit 2021 年 4 月 16 日
Thanks a lot
Star Strider
Star Strider 2021 年 4 月 16 日
As always, my pleasure!
Karl Zammit
Karl Zammit 2021 年 4 月 19 日
Would oyu by any chance also know the answer to this question please ? ReadTable
Star Strider
Star Strider 2021 年 4 月 19 日
It would appear that Walter Roberson got there first. I will add an Answer if Walter’s does not do what you want.
The problem with your original code to read that file is that it did not account for every column. Consider using this textscan call instead:
dataBuffer = textscan(finputCdCl, repmat('%f',1,7), 'CollectOutput', 1, ... %Read data from file
'Delimiter', '', 'HeaderLines', 12);
I did not test that with that file, however it would likely do what you want. If it does, and if the readtable approach does not work the way you want it to, I will add this as an Answer. Also, if you want to save the columns as separate cell arrays, set 'CollectOutput' to 0. Check to be certain that the 'Delimiter' is correct, since it could be '\t'.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by