"Matrix dimensions must agree"

 Respuesta aceptada

Massimo Zanetti
Massimo Zanetti el 28 de Sept. de 2016

0 votos

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 comentario

Massimo Zanetti
Massimo Zanetti el 28 de Sept. de 2016
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Centro de ayuda y File Exchange.

Preguntada:

N/A
el 28 de Sept. de 2016

Editada:

N/A
el 28 de Sept. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by