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.
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
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개)

카테고리

질문:

2021년 4월 15일

댓글:

2021년 4월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by