How to create a 2x2 matrix out of 4 matrices?
Show older comments
I have 3 matrices, each of size 1x100000 and the fourth element is a single numerical value. I am trying to make a square matrix 'Z' of size 2x2 which shall contain each of these 4 elements and do some operations on its inverse.
Could you please tell how I can do that?
5 Comments
Sean de Wolski
on 31 Jan 2011
How can a matrix with 4*1000000 elements be size 2x2?
Please be clear and provide a small example.
Jan
on 31 Jan 2011
How do you want to reduce the number of elements? Which of the resulting 400.000 elements should be used to create the wanted 4 elements??
Santosh Kasula
on 31 Jan 2011
Ananth, moving your comments here:
Ok, I want the final matrix of size 2x2 to contain 4 elements, each with 1x100000 values. Then, take its inverse. Could I do that by padding the 4th element with zeros to make the dimensions equal to the other 3 sub-matrices? The context is impedance calculations. The 100000 values are those multiplied by frequency points.
Santosh Kasula
on 31 Jan 2011
the cyclist says:
It's still not 100% clear to me what you want. Do you expect, in effect, to be taking the inverse of 100,000 2x2 matrices?
Santosh Kasula
on 31 Jan 2011
Ananth says:
I was trying to comment but instead pressed 'accept'. Cyclist, you are right. I am trying to take the inverse of the 100,000 2x2 matricces. But, the problem is inverses can be taken only on square matrices. I am unsure how to tackle this. Any suggestions?
Accepted Answer
More Answers (2)
the cyclist
on 31 Jan 2011
It's not entirely clear to me what you want the output matrix to look like, so this is a guess. Using Paulo's notation for your input arrays, then
>> z = reshape([mat1; mat2; mat3; mat4], [2 2 100000]);
will give you a 2x2x100000 array where each "slice" is a 2x2, with one element from each of the input matrices. Is that what you want?
James Tursa
on 1 Feb 2011
0 votes
You might also look at Bruno Luong's FEX submission for this particular problem:
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!