how to solve this nonlinear equation?

1 次查看(过去 30 天)
m = 4.7542;
gsms = 12.684 ;
m1 = (m - gss);
p = 0.1 : 0.5 : 10 ;
k = (3 * p * pi^2 / 2)^(1/3) ;
k1 = sqrt(k^2 + m1^2);
F = (gsms * m1 * (k1 - m1^2/2 *log((k1+k)/m1))/pi^2 )-gss ;
  2 个评论
Tayyab Khalil
Tayyab Khalil 2021-5-21
Can you clearly desribe which equation you want to solve and for which variable?
Dyuman Joshi
Dyuman Joshi 2021-5-21
What is gss?
Also, you have defined k and k1 incorrectly, use elementwise operators (.*)

请先登录,再进行评论。

采纳的回答

Torsten
Torsten 2021-5-21
编辑:Torsten 2021-5-22
function main
p=0.1:0.5:10;
gss0 = 1.0;
for i=1:numel(p)
gss(i)= fzero(@(x)fun(x,p(i)),gss0)
gss0 = gss(i);
end
plot(p,gss)
end
function gssres = fun(gss,p)
m = 4.7542;
gsms = 12.684;
m1 = m - gss;
k = (3*p*pi^2 / 2)^(1/3);
k1 = sqrt(k^2+m1^2);
F = gsms*m1*( k1-m1^2/2*log((k1+k)/m1) )/pi^2 - gss
gssres = F ;
end
Maybe you will have to change gss0 = 1.0 (a guess for gss for p=0.1) to make the program start.

更多回答(1 个)

Mike Mierlo van
Mike Mierlo van 2021-5-21
Please specify variable: 'gss'. This one is unknown in your function.
Also what Tayyab says: what do you want to solve?
It helps a lot if you comment with % after each line what the variable means.

类别

Help CenterFile Exchange 中查找有关 Nonlinear Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by