How to split 3d matrix into sub-2d matrices?

조회 수: 4 (최근 30일)
BN
BN 2020년 1월 27일
편집: BN 2020년 1월 27일
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
Bob Thompson
Bob Thompson 2020년 1월 27일
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.
BN
BN 2020년 1월 27일
Dear Bob Nbob,
This 3d Matrix (Latitude x Longitude x Time) belongs to gridded precipitation for a climate model named GPCC. As you can see its includes data for 408 months across 1280 points (40 x 32) covering my case study. I want to consider every point like a point-based data and produce 408-month data for them. So every 1280 point has it's owned data (let be precipitation) for 408 months. And then I can use them in the Standardized Drought Analysis Toolbox (SDAT) which is a third party function that presents in Matlab file exchange by Professor Amir Aghakouchak for calculating SPI.
Thank you in advance

댓글을 달려면 로그인하십시오.

답변 (1개)

James Tursa
James Tursa 2020년 1월 27일
편집: James Tursa 2020년 1월 27일
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.
  댓글 수: 2
BN
BN 2020년 1월 27일
편집: BN 2020년 1월 27일
Dear James Tursa,
This 3d Matrix (Latitude x Longitude x Time) belongs to gridded precipitation for a climate model named GPCC. As you can see its includes data for 408 months across 1280 points (40 x 32) covering my case study. I want to consider every point like a point-based data and produce 408-month data for them. So every 1280 point has it's owned data (let be precipitation) for 408 months. And then I can use them in the Standardized Drought Analysis Toolbox (SDAT) which is a third party function that presents in Matlab file exchange by Professor Amir Aghakouchak for calculating SPI (Standardized precipitation Index).
Thank you in advance
BN
BN 2020년 1월 27일
Oh, If it possible to index what I want, I think it would be awesome. But, I do'nt know how to index what I want. Then I can use indexed month as input for SDAT toolbox.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by