How to plot a polynomial?
10 ビュー (過去 30 日間)
古いコメントを表示
Hi I am trying to plot this polynomial but it keeps graphing as a straight line. Can anyone help?
%% Part 2
% This is the graphing portion of the problem
xi = [0,7];
fend = -2+(6.*xi)-(4.*(xi.^2))+(.5.*(xi.^3));
plot(xi,fend,'r');
xlabel('X');
ylabel('f(x)');
title('Root Find of F(x) = -2+6x-4x^2+0.5x^3');
0 件のコメント
採用された回答
Sam Chak
2022 年 10 月 7 日
Should try like this:
xi = linspace(-2, 8, 101);
fend = - 2 + (6*xi) - 4*(xi.^2) + (0.5*(xi.^3));
plot(xi,fend,'r');
xlabel('X');
ylabel('f(x)');
title('Root Find of F(x) = -2+6x-4x^2+0.5x^3');
1 件のコメント
Sam Chak
2022 年 10 月 7 日
編集済み: Sam Chak
2022 年 10 月 7 日
xi = [0,7]
fend = -2+(6.*xi)-(4.*(xi.^2))+(.5.*(xi.^3))
@Sarah Elena Aiko Johnson, the reason is because there only two points in
. When they are passed to fend for evaluation, it will also return two points.
. When they are passed to fend for evaluation, it will also return two points.And when you attempt to plot (connect a line between two points), it definitely gives a straight line. In my Answer, I created 101 data points between
.
.その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
