フィルターのクリア

minimum element of each matrix belonging to a 4d matrix

1 回表示 (過去 30 日間)
RuiQi
RuiQi 2016 年 6 月 22 日
編集済み: the cyclist 2016 年 6 月 22 日
I have a 4D matrix which you can think of as an array of matrices. How do i find the minimum value of each matrix ?

採用された回答

the cyclist
the cyclist 2016 年 6 月 22 日
編集済み: the cyclist 2016 年 6 月 22 日
You don't specify which dimension hold the matrices you want to get the minimum values of. However, you should be able to get the idea for an algorithm from this. You just have to properly reshape (and possibly shift some dimension around using permute) to line up the values you want the minimum of.
% Some pretend data
M = rand(2,3,4,5)
% Supposing I don't know the size, I get it
S = size(M)
% Reshape such that each array is now a column
R = reshape(M,prod(S(1:3)),[]);
% Get the minimum values
V = min(R)
  3 件のコメント
RuiQi
RuiQi 2016 年 6 月 22 日
Thanks ! I managed to get it to work but I found reshape easier to understand
the cyclist
the cyclist 2016 年 6 月 22 日
編集済み: the cyclist 2016 年 6 月 22 日
Walter, the reason he does need to do at least some of that work is that he is not taking a min along a dimension, but rather wants the minimum of a series of matrices. So, he needs to reshape those matrices into their own single dimension. (My answer didn't illustrate that well, but seems like he figured it out.)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by