FSOLVE with For loop

조회 수: 1 (최근 30일)
Kon Syro
Kon Syro 2021년 1월 2일
댓글: David Hill 2021년 1월 3일
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