FSOLVE with For loop

1 visualización (últimos 30 días)
Kon Syro
Kon Syro el 2 de En. de 2021
Comentada: David Hill el 3 de En. de 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

Respuestas (1)

David Hill
David Hill el 2 de En. de 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 comentarios
Kon Syro
Kon Syro el 3 de En. de 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 el 3 de En. de 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);

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by