Error using plot Vectors must be the same lengths.

x=0:4*pi;
y1=3.0*cos(x)-0.5*sin(x);
y2=diff(y1);
plot(x,y1,'r',x,y2,'b')
i want to plot those y1 , y2 in one graph but it said
Error using plot
Vectors must be the same lengths.
what should i do???

回答 (1 件)

Stephen23
Stephen23 2016 年 3 月 24 日

1 投票

Use gradient instead of diff:
y2 = gradient(y1);

1 件のコメント

kun hyung kim
kun hyung kim 2016 年 3 月 24 日
OMG you're a genius like a Alphago

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

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

質問済み:

2016 年 3 月 24 日

コメント済み:

2016 年 3 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by