FSOLVE with For loop

1 次查看(过去 30 天)
Kon Syro
Kon Syro 2021-1-2
Hello , i need your help
i have the function F(x,b) = x.^3.*b+exp(-b.^2)+x.*b - 500
I have to make a plot(x,b)
x is constant and takes values from 0 to 30
I have to use fsolve and for loop to solve this but i dont know exactly how to do it
please help

回答(1 个)

David Hill
David Hill 2021-1-2
Not sure what values you what for b, but you will not to do a surf plot or plot3 (3d plot)
f=@(x,b)x.^3.*b+exp(-b.^2)+x.*b-500;
[x,b]=meshgrid(0:30,-2:.1:2);
surf(x,b,f(x,b));
  2 个评论
Kon Syro
Kon Syro 2021-1-3
x is constant and takes values from 0 to 30.
I have to solve this non linear equation with fsolve and for every b from 0 to 30 (with step 1) find the counterpart b ,and then create the 2d plot(x,b)
Have you any idea ?
thanx
David Hill
David Hill 2021-1-3
Your description is not clear at all. After your comment, I assume you want to find the root (zero-crossing) of the non-linear equation. Of course, there is no solution at b=0.
for b=1:30
X(b)=fzero(@(x)x.^3.*b+exp(-b.^2)+x.*b-500,1);
end
plot(1:30,X);

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by