FSOLVE with For loop

1 visualizzazione (ultimi 30 giorni)
Kon Syro
Kon Syro il 2 Gen 2021
Commentato: David Hill il 3 Gen 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

Risposte (1)

David Hill
David Hill il 2 Gen 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 Commenti
Kon Syro
Kon Syro il 3 Gen 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 il 3 Gen 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);

Accedi per commentare.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by