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

2 ビュー (過去 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 Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by