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]
采纳的回答
Look up documentation on fzero.
11 个评论
I have no initial point to solve this ....
>> 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.
Plot a curve of the right hand side Vs n, to see roughly where it equals R.
You need to supply an initial guess. Also MATLAB use log not ln, for log to the base e.
You need to pass the initial guess to fzero as its second argument.
see i guess x=5 but still did not get the answer....
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)
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 ....
But what is wrong with writing a loop? Just wrap that code inside a loop, where you change R each time through.
Earlier my code did not work with the loop but now I have fixed the error... it works perfectly .. Thanks
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Mathematics 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)

