Plotting a polynomial function with roots

2 次查看(过去 30 天)
Hi there! I have barely have an idea of what to do with MatLab as of now and my professor pretty much leaves us to do the problems on our own without even teaching the basics first.
He gave us this problem: plot the function showing its roots. Label the roots r1, r2, etc.
f(x) = (x^3) - 10/((2-x)^2) + 25
i got one root through the fixed point iteration method which is roughly 1.3997 but i don't know how to plot this. Any help would be highly appreciated. Thanks in advance!
  1 个评论
Robert
Robert 2016-10-23
编辑:Robert 2016-10-23
Please don't forget to accept the answer Thanks!
syms x
f = (x^3) - 10/((2-x)^2) + 25 % Original function
%same function but rearranged
%Matlab needs to rearrange the function to be in the form of a polynomial
f_rearranged = x^5 -4*x^4 + 4*x^3 +25*x^2 -100*x+90
% Collect the coefficients in decending order
[My_coeffs,~] = coeffs(f_rearranged,x)
roots(My_coeffs) %Get the roots

请先登录,再进行评论。

回答(1 个)

Andrei Bobrov
Andrei Bobrov 2016-10-23
syms x
f = x^3 - 10/(2-x)^2 + 25
[n,~] = numden(f);
[c,~] = coeffs(n);
your_roots = roots(double(c));
your_roots = your_roots(imag(your_roots)==0)

类别

Help CenterFile Exchange 中查找有关 Spline Postprocessing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by