I am trying to normally plot y=x^3, but matlaab is not plotting in -ve direction
my code is
x=linspace(-10,10,100);
y=x.^3;
plot(y)
please help me

回答 (1 件)

Steven Lord
Steven Lord 2019 年 2 月 20 日

0 投票

plot(Y) creates a 2-D line plot of the data in Y versus the index of each value.
  • If Y is a vector, then the x-axis scale ranges from 1 to length(Y).
Instead you want:
plot(X,Y) creates a 2-D line plot of the data in Y versus the corresponding values in X.
  • If X and Y are both vectors, then they must have equal length. The plot function plots Y versus X.

カテゴリ

タグ

質問済み:

2019 年 2 月 20 日

回答済み:

2019 年 2 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by