element wise multiplication (beginner)

4 visualizaciones (últimos 30 días)
Nikola
Nikola el 3 de Feb. de 2015
Comentada: Nikola el 3 de Feb. de 2015
c=[1 2 3 4 5 6 7]
and
d=[11 ;12 ;13;14;15;12;22],
f=c.*d wouldn't do the job. I got this: "Error using .* Matrix dimensions must agree."
Sorry i am beginner in matlab. Could you share me a solution, thanks.

Respuesta aceptada

James Tursa
James Tursa el 3 de Feb. de 2015
c is a 1x7 row vector (built with spaces or commas separating the elements)
d is a 7x1 column vector (built with semi-colon separating the elements)
So you need to convert one to the other shape first. E.g.,
c(:) .* d % The (:) notation converts c into a column vector
  1 comentario
Nikola
Nikola el 3 de Feb. de 2015
that was the answer i was looking for. Thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by