Plotting a polynomial function with roots
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Robert
il 23 Ott 2016
Modificato: Robert
il 23 Ott 2016
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
Risposte (1)
Andrei Bobrov
il 23 Ott 2016
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 Commento
Vedere anche
Categorie
Scopri di più su Spline Postprocessing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!