Iterating an equation using while loop

I have an equation describing Area ratio of a nozzle and exit Mach number
Area_ratio = (1/Mach_number)*((2/(k+1))*(1+((k-1)/2)*(Mach_number)^2))^((k+1)/(2*k-1))
I want to be able to input an area ratio and get the corresponding mach number as the output. The equation is too complex to rearrange, and I cant figure out how to create an iterative loop to solve it. This is what I attempted:
Ar = 50
Ma_guess = 0.1 % Initial Mach number guess
Ar_guess = Ar_guess = (1/Ma_guess)*((2/(k+1))*(1+((k-1)/2)*(Ma_guess)^2))^((k+1)/(2*k-1)) % Initial Area Ratio Guess
while Ar_guess < Ar
Ma_guess = Ma_guess + 0.01 ;
Ar_guess = Ar_guess = (1/Ma_guess)*((2/(k+1))*(1+((k-1)/2)*(Ma_guess)^2))^((k+1)/(2*k-1)) ;
end
Ma = Ma_guess
I know it's wrong but gives you a bit of an idea of what I'm trying to do.
All help would be much appreciated.
Kind regards,
barney

回答 (1 件)

Torsten
Torsten 2022 年 4 月 20 日
編集済み: Torsten 2022 年 4 月 20 日

0 投票

k = 1.4;
Ar = 50;
Ma_guess = 0.1; % Initial Mach number guess
fun = @(M) Ar - (1/M)*((2/(k+1))*(1+((k-1)/2)*(M)^2))^((k+1)/(2*k-1));
Ma = fzero(fun,Ma_guess)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

製品

リリース

R2022a

質問済み:

2022 年 4 月 20 日

編集済み:

2022 年 4 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by