Trimming matrices to smallest size

4 ビュー (過去 30 日間)
Prodip Das
Prodip Das 2019 年 8 月 16 日
編集済み: Prodip Das 2019 年 8 月 16 日
Hello,
I need to find a way to automate this process.
I have a 1-by-8 cell, which consists of 8 3D matrices. Each matrix is approximately n x m x p in size. I need to make them exactly n x m x p by trimming the highest end.
Details -
S is a 1 by 8 cell
where each cell element is supposed to be n x m x p. There are (can be) cell elements which can go (n+1) x m x p or n x (m+1) x p. etc.
I need to identify the matrix with smallest dimension on each end (n x m x p) and trim the rest 7 if needed to this value.
Any leads appreciated.
Thanks!

採用された回答

Walter Roberson
Walter Roberson 2019 年 8 月 16 日
minsize = min(cell2mat(cellfun(@size, S(:), 'uniform', 0)));
newS = cellfun(@(M) M(1:minsize(1), 1:minsize(2), 1:minsize(3)), S, 'uniform', 0);

その他の回答 (1 件)

Prodip Das
Prodip Das 2019 年 8 月 16 日
編集済み: Prodip Das 2019 年 8 月 16 日
That works perfectly well and is so self-explanatory!
Thanks Walter.

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by