Plotting a given function over an interval

8 ビュー (過去 30 日間)
Jordan
Jordan 2022 年 11 月 14 日
コメント済み: VBBV 2022 年 11 月 14 日
I am given the following function:
f(x) = x^5 - 6.13x^2 - 0.83x - (0.62 / (x^2 + 0.0825)) + 5.2
and I am wanting to plot this function over an interval from -1.5 to 1.5 to determine the roots of this function but whenever I try to plot the function using the following:
x1 = -1.5 : 0.1 : 1.5;
y1 = (x.^5) - (6.13*x.^2) - (0.83*x) - (0.62 ./ (x.^2 + 0.0825)) + 5.2;
plot(x1,y1);
it errors and says that the 'vector must be the same length' and whenever I am able to get the plot to plot, then it plots a vertical line, whereas the actual function has 4 different zeros along the given interval. Please help....
  1 件のコメント
Jordan
Jordan 2022 年 11 月 14 日
I've also tried using the 'fplot' command and the command itself errors out with a bunch of underlying errors as well.

サインインしてコメントする。

回答 (1 件)

VBBV
VBBV 2022 年 11 月 14 日
syms x
y1 = (x.^5) - (6.13*x.^2) - (0.83*x) - (0.62 ./ (x.^2 + 0.0825)) + 5.2;
fplot(y1,[-1.5 1.5]) % range of values
  1 件のコメント
VBBV
VBBV 2022 年 11 月 14 日
x1 = -1.5 : 0.1 : 1.5;
y1 = @(x) (x.^5) - (6.13*x.^2) - (0.83*x) - (0.62 ./ (x.^2 + 0.0825)) + 5.2; % without symbolic variables
plot(x1,y1(x1));
you can use anonymous function to plot graph or use symbolic variables and graoh using fplot

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by