how do i find the roots of this function? the function is attached

x=-10:1:10;
y=x.^3-x.^2+5.*x.*sin((pi().*x)/4-(pi()*5)/4)+3;
y1=0;
plot(x,y,x,y1)
xlabel('x'); grid on
ylabel('y')

Answers (2)

syms x
y=x^3-x^2+5*x*sin(pi*x/4-5*pi/4)+3
solve(y)
To find all the roots, you can use fsolve
y=@(x) x^3-x^2+5*x*sin(pi*x/4-5*pi/4)+3
x0=-0.5 % first starting point
x1=fsolve(y,x0)
x0=2 % second starting point
x2=fsolve(y,x0)

2 Comments

i do not have the symbolic math toolbox is there another way to do this?
i do not have any add-ons to matlab. just the base student edition. for the fsolve i need optimization toolbox

Sign in to comment.

Torsten
Torsten on 15 Aug 2016
Edited: Torsten on 15 Aug 2016
Plot the function and use "fzero" to determine the roots with appropriate starting intervals taken from your graphical inspection.
Best wishes
Torsten.

Categories

Find more on Function Creation in Help Center and File Exchange

Tags

Asked:

on 12 Aug 2016

Edited:

on 15 Aug 2016

Community Treasure Hunt

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

Start Hunting!