MATLAB Answers

0

vector multiplication and dot product

Asked by pravin behera on 11 Apr 2015
Latest activity Answered by Roger Stafford on 12 Apr 2015
i have 2 matrix and i want to do matrix multiplication, but the elements in matrix are vectors, so i want to take dot product of the elements, can u suggest me a way...
q=[a b;c d]*[e f]
where
a=[1 2 3]=b=c=d=e=f
the output will be [a.e+b.f ; c.e+d.f]
and expected output is [28;28]
please suggest a good way to tackle this problem

  2 Comments

Please post the matrix q in valid Matlab syntax. It is not clearly defined yet. Do you mean this:
q = [1,2,3,1,2,3; ...
1,2,3,1,2,3]
q=[(1 2 3) (1 2 3); (1 2 3) (1 2 3)] * [(1 2 3) ; (1 2 3)]
=[ (1 2 3).((1 2 3) + (1 2 3).(1 2 3) ; (1 2 3).((1 2 3) + (1 2 3).(1 2 3)]
=[14+14 ;14+14]
=[28;28]
this is what i want to do

Sign in to comment.

1 Answer

Answer by Roger Stafford on 12 Apr 2015
 Accepted Answer

You cannot have the grouping q = [(1 2 3) (1 2 3); (1 2 3) .... for ordinary matrices, but you can do this:
[1 2 3 1 2 3;1 2 3 1 2 3]*[1 2 3 1 2 3].'
where ".'" denotes the transpose and the result will be [28;28].

  0 Comments

Sign in to comment.