"Matrix dimensions must agree"

 Accepted Answer

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 Comment

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.

Sign in to comment.

More Answers (0)

Categories

Asked:

N/A
on 28 Sep 2016

Edited:

N/A
on 28 Sep 2016

Community Treasure Hunt

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

Start Hunting!