How to change the dimensions of a matrix?

2 ビュー (過去 30 日間)
Shayma Al Ali
Shayma Al Ali 2023 年 4 月 14 日
回答済み: Dave B 2023 年 4 月 14 日
I have a list of matrices with dimensions of time x latitude x longitude (733x311x720). I'd prefer the matrices to have dimensions of latitude x longitude x time (311x720x733) that way I can concatenate all of them into one matrix and organize them by time. Is there any way I can do this? I read about reshape but I'm not sure it'll do what I want.

回答 (1 件)

Dave B
Dave B 2023 年 4 月 14 日
You could use permute to do this, though it's maybe worth noting that you can concatenate matrices regardless of the shape (you might want the cat function to help)
x=reshape(1:24,3,4,2);
y=permute(x, [3 1 2])
y =
y(:,:,1) = 1 2 3 13 14 15 y(:,:,2) = 4 5 6 16 17 18 y(:,:,3) = 7 8 9 19 20 21 y(:,:,4) = 10 11 12 22 23 24

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by