Plotting a polynomial function with roots

조회 수: 2 (최근 30일)
Christina Cruz
Christina Cruz 2016년 10월 23일
댓글: Robert 2016년 10월 23일
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)
  댓글 수: 1
Robert
Robert 2016년 10월 23일
Why are you removing imaginary roots? The answer is incomplete

댓글을 달려면 로그인하십시오.

카테고리

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