How to solve an equation using numerical solver in Matlab?

Hi everyone,
I want to solve this equation using numerical solver. I have value of R and want to calculate the coressponding value of n using numerical solver.
May someone help me here ......
R =1/n^2 [(n+1)ln(n+1)-n]

 採用された回答

Alan Stevens
Alan Stevens 2020 年 9 月 30 日

0 投票

Look up documentation on fzero.

11 件のコメント

aa
aa 2020 年 9 月 30 日
I have no initial point to solve this ....
aa
aa 2020 年 9 月 30 日
>> x = fzero(@(x)x^(-2)*((x+1)*ln(x+1)-x)-0.44999)
Error using fzero (line 118)
The input should be either a structure with valid fields or at least two arguments to FZERO.
Alan Stevens
Alan Stevens 2020 年 9 月 30 日
Plot a curve of the right hand side Vs n, to see roughly where it equals R.
Alan Stevens
Alan Stevens 2020 年 9 月 30 日
You need to supply an initial guess. Also MATLAB use log not ln, for log to the base e.
aa
aa 2020 年 9 月 30 日
Alan Stevens
Alan Stevens 2020 年 9 月 30 日
You need to pass the initial guess to fzero as its second argument.
aa
aa 2020 年 9 月 30 日
see i guess x=5 but still did not get the answer....
Alan Stevens
Alan Stevens 2020 年 9 月 30 日
Try
R = 0.44999;
f = @(n) ((n+1).*log(n+1)-n)./n.^2 - R;
n0 = 1; % Initial guess
n = fzero(f,n0);
disp(n)
aa
aa 2020 年 9 月 30 日
May you help me in generalizing this programme for large number of values. For example, I have more tahn 500 values of R and I want to calculate n for each values of R ....
John D'Errico
John D'Errico 2020 年 9 月 30 日
But what is wrong with writing a loop? Just wrap that code inside a loop, where you change R each time through.
aa
aa 2020 年 9 月 30 日
Earlier my code did not work with the loop but now I have fixed the error... it works perfectly .. Thanks

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

その他の回答 (0 件)

カテゴリ

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

質問済み:

aa
2020 年 9 月 30 日

コメント済み:

aa
2020 年 9 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by