"Matrix dimensions must agree"

 採用された回答

Massimo Zanetti
Massimo Zanetti 2016 年 9 月 28 日

0 投票

Of course it gives you an error. In your script
x=0:0.01:6
is a vector of size 1x601. When you do elementwise multiplication
M=eye(3).*x;
you are trying to multiply a 3x3 matrix with a 1x601 vector, which is impossible.

1 件のコメント

Massimo Zanetti
Massimo Zanetti 2016 年 9 月 28 日
To obtain the graph of y=3x just do this:
x = 0:0.01:6;
y = 3*x;
plot(x,y);
You don't need to go through matrix multiplication in Matlab for elementwise multiplication of a vector (or a matrix) with a scalar.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

質問済み:

N/A
2016 年 9 月 28 日

編集済み:

N/A
2016 年 9 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by