How to split 3d matrix into sub-2d matrices?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a 3d matrix (40 x 32 x 408). I want to split it to the separate matrix like this:
1 x 1 x 1 (Get first value of firs dimension and first value of second dimension, first of third dim)
1 x 1 x 2 (Get first value of firs dimension and first value of second dimension, second of third dim)
1 x 1 x 3 (Get first value of firs dimension and first value of second dimension, third of third dim)
...
1 x 1 * 408
Be a separate 3d matrix.
Then:
1 x 2 x 1 (Get first value of firs dimension and second value of second dimension)
1 x 2 x 2
1 x 2 x 3
...
1 x 2 x 408
Be another separate matrix; and continue this for all 32 values. Also similar for 40 dimensions:
2 x 1 x 1 (Get second value of firs dimension and first value of second dimension)
2 x 1 x 2
2 x 1 x 3
...
2 x 1 x 408
And so on. So in that way (at the end), I must have 40 x 32 = 1280 separate 3d matrix which the third dimension for all of them starts in 1 and ends in 408.
I attached my 3d matrix. I appreciate for any help.
Thank you
2 Commenti
Bob Thompson
il 27 Gen 2020
What are you looking to do with these different matrices? I think most people will consider the division less efficient than just indexing the different sections as needed.
Risposte (1)
James Tursa
il 27 Gen 2020
Modificato: James Tursa
il 27 Gen 2020
I agree with Bob ... just using indexing downstream in your code will be much easier. If you really do need them in separate variables for some reason you haven't told us about, I would suggest looking at the mat2cell( ) function. This will still allow you to get at the individual variables with indexing.
https://www.mathworks.com/help/matlab/ref/mat2cell.html?searchHighlight=mat2cell&s_tid=doc_srchtitle
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!