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.

Concatenating n by n matrices in matlab

Status
Not open for further replies.

shegmite

Member level 1
Member level 1
Joined
Apr 8, 2012
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,496
Please can anyone help with matlab codes on how to concatenate or carry out sequential multiplication of n number of say 2 by 2 matrices in matlab.
I want to use the knowledge to cascade multiple T matrices .
Thanks
 

What i mean is something like this : A1*A2*A3*A4*A5*...*An
Where A1, A2 are complex 2 by 2 matrices such as : 0.0123+0.0345i 0.0334+0.0878i
0.0345-0.0988i 0.0998-0.08767i
 


N = 10; % arbitrary number of matrices
myArray = zeros(2,2,N); % create an array of N 2x2 matrices. real/complex doesn't matter
product = eye(2); % initialize product to be 1 (identity matrix)
for j=1:length(myArray)
product = product * myArray:),:,j);
end
product
 
Thanks so much for your effort so far.I am grateful.Please could you help me further on how to use that codes you sent and apply it to a matrix say
A1=[0.2408-0.0056918i -0.75918-0.0049211i ; 0.75918+0.0049211i 1.7592+0.010552i]
.
.
.
A10 =[0.2408-0.0056918i -0.75918-0.0049211i ; 0.75918+0.0049211i 1.7592+0.010552i]
i.e say 10 same matrices as above .
If it is to be done for 10 different matrices does the program differ from above ?
Thanks
 

A few questions first,
- is the number of matrices 'N' a fixed value ?
- do you know beforehand the dimensions and/or values for each matrix ?

If the answer to both is yes, then why don't you just write


P = A1*A2*A3*A4*A5*A6*A7*A8*A9*A10
 
Thanks for your patience.What i wanted to do is to have a code that can multiply sequentially large number of same matrix upto 1000 i.e say A1,A2,A3....AN = [0.9987+0.6544i 0.0877+0.0766i;0.0987+0.0977i 0.0087+0.0987i] without having to write out one by one the matrices i want to multiply.
Thanks
 

In my original code, I had used zero matrices throughout. You just have to change them to suit your case.


N = 10; % arbitrary number of matrices
myArray = zeros(2,2,N);
myArray:),:,1) = [0.2408-0.0056918i -0.75918-0.0049211i ; 0.75918+0.0049211i 1.7592+0.010552i];
myArray:),:,2) = [ ... ...; ... ...];
.
.
.
myArray:),:,10) = [0.2408-0.0056918i -0.75918-0.0049211i ; 0.75918+0.0049211i 1.7592+0.010552i];
product = eye(2); % initialize product to be 1 (identity matrix)
for j=1:length(myArray)
product = product * myArray:),:,j);
end
product
 
Many thanks for your noble knowledge and kindness.I will try it out.
 

Thanks.I have tried the codes but the matlab is pointing error signs at the dots ... used to represent repetition of matrices upto 10.It like there is a problem with it ?
 

:|
I meant for the dots to be replaced with the values of the matrices that you use .

What are the values for your matrices from A1 to A10 ?
 
Does that mean if i am to do for a large number of multiplication of matrices upto say 100 ,i will have to state the matrices a hundred times ? Is there no way to make the computer repeat it itself by just inputing the first and last matrices let say the first one and the last one which is 100 since the matrices are same.
Thanks.
 

If the matrices are all the same, why don't you just use the power function ?

A = [0.2408-0.0056918i -0.75918-0.0049211i ; 0.75918+0.0049211i 1.7592+0.010552i];
N=100;
product = mpower(A,N);
 
I tried your codes and it worked perfectly.Many thanks for this solution .
 

Thanks for your support the other time.In the multiple matrix answer you gave i.e as shown below :
A = [0.2408-0.0056918i -0.75918-0.0049211i ; 0.75918+0.0049211i 1.7592+0.010552i];
N=100;
product = mpower(A,N);
disp(product)
Is it possible to make the above display the( product )as T1=
T2=
T3=
T4=
which represent the 2 by 2 matrix.Thanks
 

If you want to display the individual matrix elements, you can refer to them directly.

disp(product(1,1))
disp(product(1,2))
disp(product(2,1))
disp(product(2,2))
 
Many thanks again .It worked perfectly .
 

i want to concatenate around a 100 2D matrices into a 3D matrix.

e.g cat[3,A,B]

would combine the A and B matrices into a 3D matrix
say if i want to combine 100 matrices into a 3D matirx id have to use this command

cat[3,A1,A2,A3...]
which is tedious
any solutions?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top