FSOLVE with For loop

1 view (last 30 days)
Kon Syro
Kon Syro on 2 Jan 2021
Commented: David Hill on 3 Jan 2021
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

Answers (1)

David Hill
David Hill on 2 Jan 2021
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 Comments
Kon Syro
Kon Syro on 3 Jan 2021
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 on 3 Jan 2021
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);

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!