how to multiply matrix 2 * 2 if the elements of the matrix are row vectors.
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Example:
fre=100:100:1000;
A1=1; B1=5; C1=0; D1=1;
Matrix1=[A1 B1;C1 D1];
A2=1; B2=sin(2*pi*fre); C2=0; D2=1;
Matrix2=[A2 B2;C2 D2];
MatrixTotal=Matrix1*Matrix2 ???
4 Comments
Shaun VanWeelden
on 15 Jul 2013
Darn it Matt, I just created a whole long answer and now can't post it because its closed hahaha So I will post it in the comment I guess
That was a very confusing way of displaying your matrices and question...
In my mind, I see them like this: (tell me if I am right)
mat1=[1 1 0 2];
mat2=[4 5 1 3];
And you want to multiply them to get:
total=[4 5 0 6] ??
Is that correct?
If so, then just do:
total = mat1 .* mat2 %(note the ".")
One problem I see is that B2 is not equal to a number, but rather a vector. Either change this to a single number or use a for loop to go through each element of fre
Ed
on 15 Jul 2013
dpb
on 16 Jul 2013
Well, you've got to define precisely what it is you mean to multiply by what...you've got a square matrix of 2x2 and another that isn't regular and could only be written in Matlab as a cell array as containing a constant and a vector on one row and two constants on the second.
Now, what is the result wanted?
Give an actual demonstration using, say, only 3 values for the vector length. Perhaps even just working that out algebraically will give you the clue you need to write the Matlab code but even if not at least it will give the readers here an idea of what you mean...the crystal ball is cloudy this morning, sorry.
Answers (3)
Miroslav Balda
on 16 Jul 2013
Your task is rather simple, and as a matter of fact , you have almost solve it. The a bit modified code is as follows:
% Ed.m 2013-07-16
A1=1; B1=5; C1=0; D1=1;
Matrix1=[A1 B1;C1 D1]
for fre=100:100:1000;
A2=1; B2=sin(2*pi*fre); C2=0; D2=1;
Matrix2=[A2 B2;C2 D2];
MatrixTotal=Matrix1*Matrix2
end
When you run the code you get:
>> Ed
Matrix1 =
1 5
0 1
MatrixTotal =
1.0000 5.0000
0 1.0000
MatrixTotal =
1.0000 5.0000
0 1.0000
MatrixTotal =
1.0000 5.0000
0 1.0000
MatrixTotal =
1.0000 5.0000
0 1.0000
MatrixTotal =
1.0000 5.0000
0 1.0000
MatrixTotal =
1.0000 5.0000
0 1.0000
MatrixTotal =
1.0000 5.0000
0 1.0000
MatrixTotal =
1.0000 5.0000
0 1.0000
MatrixTotal =
1.0000 5.0000
0 1.0000
MatrixTotal =
1.0000 5.0000
0 1.0000
The result is not surprising, because you get 10 times almost the same result as Matrix1. The reason is clear - sin(2*pi*integer)=0, what means that Matrix2 equals unity matrix. Why MatrixTotal does not equal Matrix1 exactly? The function sin(2*pi*fre) does not equal 0 precisely due to rounding errors in calculating sin of large argument.
It is all.
Mira
David (degtusmc)
on 16 Jul 2013
0 votes
Try converting to matrix and then multiplying using vec2mat. The link for the documentation is below, I hope this helps.
Ed
on 16 Jul 2013
0 votes
1 Comment
David (degtusmc)
on 31 Jul 2013
Ed,
Make sure to let us know if your question was answered (by accepting one of the answers). This way, everyone else in the community can see that the question is "closed".
Thanks.
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!