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
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
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spline Postprocessing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!