Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Sucessive matrix multiplication in Matlab

Status
Not open for further replies.

rameshrai

Full Member level 3
Full Member level 3
Joined
Aug 16, 2010
Messages
158
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Activity points
2,272
Hello,

I need help with matrix multiplication in matlab. I have some 2x2 matrices M, A, B, C and D related by M = A*B+C*D and want to multiple M with another 1x2 column vector E such that E only gets multiplied by B and D. How can I do that in matlab?

thanks
 

I can't understand.
Can you explain?

Z
 

how can you multiply 2x2 matrix with a 1x2 matrix.if i have understand what you have said here....are you talking about finding the eigen values??you need to first find the value of M and then get the determinant of M which gives the eigen value and multiply it with the 1x2 column vector...
 

First of all, by convention, we describe a column vector as 2x1. If it is 1x2, then it would be a row vector. Therefore, let's say E is a 2x1 column vector.

You may already know that a really important rule when multiplying matrices (and vectors) is that the dimensions that are next to each other must be the same.

Therefore, if M, A, B and C are 2x2, then the column vector E can only be multiplied at the right (e.g. M*E and B*E exist ... but E*M and E*B are meaningless). In Matlab, if you ever see the error:
Error using *
Inner matrix dimensions must agree.
then this is what it is talking about. E*M and E*B do not exist.

You may know a second really important rule is that when you multiply two matrices (or vectors), the dimension of the result is equal to the 'outer' dimensions (with the 'inner' ones deleted). For example, if we multiply (5 x 4) with (4 x 6), the result is (5 x 6). In fact, we can multiply many matrices together and use the same rule. For example:

(2x7) * (7x7) * (7x1739) * (1739x1) * (1x3) -----> (2x3)

Now, what about (5x3) * (3x7) * (6x2)? It doesn't exist, because 7 and 6 are not the same.

So, perhaps you can now clarify your question. If E is multiplied by B (or D), then B*E is (2x2)*(2x1) and gives a (2x1) column vector. What exactly are you trying to do? Or what problem are you trying to solve?
 
Last edited:

sorry, my mistake

I want to do-
Code:
M*E = (A*B+C*D)*E = A * (B*E) + C * (D*E) = A * R1 + C *R2

- so, when M is multiplied by E only B and D should acts on E
- where, the matrices M,A,B,C,D (2x2)and E (2x1) are predefined
- R1 and R2 are results of B*E and D*E
- I am not solving for eigenvalues as far as this step is concerned

Thanks
 

Then I don't understand the problem. You can just type those equations into Matlab. Which part are you having trouble with?
 

If I do M*E then whole M = A*B+C*D gets multiplied with E isn't it?
 

yes matlab will multiply M * E...your output does not change..if you want E back you divide it by M...what do you want as output?..Can u be more specific??
 

I want to multiply M by E such that only B and D matrix gets multiplied with E. I don't know how to do this, maybe make A,B,C,D identifiable part of M and then multiply with E.....
 

you have the answer in your reply itself..try this in matlab
M*E = (A*B+C*D)*E = A * (B*E) + C * (D*E) = A * R1 + C *R2
your final output should be a 2x1 matrix.
 

you have the answer in your reply itself..try this in matlab
M*E = (A*B+C*D)*E = A * (B*E) + C * (D*E) = A * R1 + C *R2
your final output should be a 2x1 matrix.

This M*E = (A*B+C*D)*E = A * (B*E) + C * (D*E) = A * R1 + C *R2 was just to explain

Of course typing M*E = (A*B+C*D)*E = A * (B*E) + C * (D*E) will give me result straight away. The problem is how to make selective multiplication of matrix elements(A,B,C,D) of M with another vector E. I mean how to multiply only B and D part of M with E.

thanks
 
Last edited:

do you mean that your end output i.e M*E should be divisible by both A and C ??
 

do you mean that your end output i.e M*E should be divisible by both A and C ??

nothing to do with divisibility, just how to make selective multiplication. I want to multiply M by E such that only B and D part of M gets multiplied by E. The output should stay as A * R1 + C *R2.

Just to tell more, in the next step another vector F multiplies the result M = A * R1 + C *R2 such that now only F gets multiplied by A and C.
 

nothing to do with divisibility, just how to make selective multiplication. I want to multiply M by E such that only B and D part of M gets multiplied by E. The output should stay as A * R1 + C *R2.

Just to tell more, in the next step another vector F multiplies the result M = A * R1 + C *R2 such that now only F gets multiplied by A and C.

you need to find the B and D part of M by doing a simulataneous eqns approach.once u find the value of M,try assigning values of A and C matrices as variables x1,x2,y1,y2 and calculates the B and D matrix values..if you already know the B and D matrix value...why cant u multiple B and D with E directly??..


you need to specify us which matrix values are available to u and which are not..
 

you need to find the B and D part of M by doing a simulataneous eqns approach.once u find the value of M,try assigning values of A and C matrices as variables x1,x2,y1,y2 and calculates the B and D matrix values..if you already know the B and D matrix value...why cant u multiple B and D with E directly??..


you need to specify us which matrix values are available to u and which are not..

All matrices A, B, C and D are available but it is a question of obtaining and analyzing intermediate values by selective multiplication of matrices.
 

I think you are confused. It is not at all clear what your question is. I will try to guess what you are asking, but it would help if you could just be more clear. What exactly are you trying to do?
I mean how to multiply only B and D part of M with E.
Perhaps you want to separate the terms like this (using Matlab syntax, transpose is denoted by .'):
Code:
R1 = B*E;
R2 = D*E;
L1 = F.'*A;
L2 = F.'*C;
disp(F.'*M*E);
disp(L1*R1 + L2*R2);
and you will see that F.'*M*E = L1*R1 + L2*R2. Perhaps this is what you mean by "only B and D part of M gets multiplied by E" and "only F gets multiplied by A and C".

- - - Updated - - -

yes matlab will multiply M * E...your output does not change..if you want E back you divide it by M...what do you want as output?..Can u be more specific??
You must be careful, as this is not correct in general. What do you even mean by "divide it by M"? M is a matrix, so perhaps you are suggesting that you can either left multiply or right multiply by M-1 (where -1 denotes matrix inverse). However, M-1 only exists if M is a square matrix and is "full rank".

For a 2x2 matrix, this means the two columns must not be collinear. If you ever see an error like this in Matlab:
Warning: Matrix is singular to working precision
then this is what it is talking about. The matrix is not full rank, so an inverse doesn't exist.

If M is non-square, then an infinite number of solutions may exist (but the Moore-Penrose pseudoinverse will conveniently provide the solution with minimum Frobenius norm).
 
Last edited:
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top