function main
pt2pinf = [1.9, 2.7, 3.5, 4.3, 5.1, 5.9, 6.7, 7.5, 27.5, 47.5, 67.5 ,87.5 ,107.5,127.5, 147.5, 200, 252.5, 305, 357.5, 410, 462.5 ,515 ,567.5, 620, 672.5, 725, 777.5, 830 ,882.5, 935, 987.5, 1000];
Me0 = 5.0;
g = 1.2;
fun = @(Me,pquot)((((1+((g-1)/2)*Me.^2).^(g/(g-1)))./((((2*g)/(g+1))*Me.^2)-((g-1)/(g+1))))-pquot).^2
for i = 1:numel(pt2pinf)
pquot = pt2pinf(i);
machnumber(i) = fminsearch(@(Me)fun(Me,pquot),Me0,optimset('TolFun',1e-10));
end
machnumber
fun(machnumber,pt2pinf)
end
8 Comments
Torsten (view profile)
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/479663-how-to-iterate-with-fsolve-to-find-mach-number#comment_744203
Hailey (view profile)
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/479663-how-to-iterate-with-fsolve-to-find-mach-number#comment_744205
Torsten (view profile)
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/479663-how-to-iterate-with-fsolve-to-find-mach-number#comment_744209
Hailey (view profile)
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/479663-how-to-iterate-with-fsolve-to-find-mach-number#comment_744212
Torsten (view profile)
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/479663-how-to-iterate-with-fsolve-to-find-mach-number#comment_744220
Hailey (view profile)
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/479663-how-to-iterate-with-fsolve-to-find-mach-number#comment_744222
Torsten (view profile)
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/479663-how-to-iterate-with-fsolve-to-find-mach-number#comment_744224
Hailey (view profile)
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/479663-how-to-iterate-with-fsolve-to-find-mach-number#comment_744256
Sign in to comment.