How can I make a few matrices have the same size?
3 views (last 30 days)
Show older comments
I have a few (well 188) matrices and they are like:
A: 207x79x256 B: 171x92x256 C: 162x95x256 D: 188x85x256 and so on
How can I cut all of then to have matrices with the same size? Preferably at once...
Thanks
1 Comment
the cyclist
on 27 Aug 2015
Edited: the cyclist
on 27 Aug 2015
You need to add more detail. For example, do want to remove elements from the larger ones, or pad elements (zeros?, NaNs?) to the smaller ones? You do say "cut", but then details about how are important. From the "top" or "bottom", for example.
Also, do you have the ability to rewrite the code that led up to this poor choice of names, A, B, C, ... ? It seems your data model could have been chosen better. For example, you might have chosen to use cell arrays, such that they are stored as A{1}, A{2}, A{3}, etc. Or maybe even have used a single 4-dimensional array.
Answers (1)
Star Strider
on 27 Aug 2015
If you have different matrices of different sizes, you likely cannot do all of them at once.
If you want to make them the same size, just define them that way:
A = rand(7,5,3)
Anew = A(1:5, 1:3, 1:2)
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices 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!