How to split 4D matrix in equal parts?

5 ビュー (過去 30 日間)
Iugo
Iugo 2020 年 10 月 16 日
コメント済み: Iugo 2020 年 10 月 18 日
Hi everyone!
I have here a doubt that consists in how can I split a 4D matrix (112x112x25x100) in equal parts and put it in 2D? This problem appeared because I will use the corrcoef function and it onluy accepts 2D input, so I need to transform this 4D matrix into 2D. And I want to split to avoid problems with the memory because this matrix is kinda big,
Hope you can help me!!
Thanks in advance,
Hugo

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 10 月 17 日
You can access a 2D component of a 4D matrix by indexing like this
x = rand(112, 112, 25, 100);
y = x(:,:,1,1); % 3rd dimension can vary to 25 and fourth to 100
Alternatively you can create a 25x100 cell array
x = rand(112, 112, 25, 100);
y = mat2cell(x, size(x,1), size(x,2), ones(size(x,3),1), ones(size(x,4),1));
y = squeeze(y);
  9 件のコメント
Walter Roberson
Walter Roberson 2020 年 10 月 17 日
For correlating the time series use
M = reshape(permute(x, [4 1 2 3], size(x,4), []);
Now each row is one observation (time) and each column is a variable (pixel location).
The result would, in theory, be a square matrix in which each pixel is correlated against each other pixel.
However... you have 313600 pixels and the correlation matrix would require about 3/4 of a petabyte.
You could break the matrix up into smaller pieces, but even if you manage to assemble it in pieces, you still have the problem that as long as correlation of every pixel to every other pixel is your goal, then your final matrix is going to have to be that size. Your only chance for success is if that is not really your final goal and your actual goal does not need as much information to represent.
Iugo
Iugo 2020 年 10 月 18 日
Thank you so much Walter! I really appreciate your help!
Cheers,
Hugo

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by