just signed up and can't figure it out as it says :"Error using plot Vectors must be the same length."
1 回表示 (過去 30 日間)
古いコメントを表示
Abdallah Almughrabi
2021 年 10 月 21 日
コメント済み: Abdallah Almughrabi
2021 年 10 月 21 日
clear
clc
x = 0:pi/16:2*pi;
f = (sin(x).^2).*cos(2*x);
k = diff(f);
plot(x,k);
0 件のコメント
採用された回答
Cris LaPierre
2021 年 10 月 21 日
The result of diff is a vector (you named it k) that has one element less than the input vector (you named it f). The error message, then, is that you inputs to the plot function are not the same length.
Try this.
x = 0:pi/16:2*pi;
f = (sin(x).^2).*cos(2*x);
k = [0 diff(f)];
plot(x,k);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!