How to find position (indices) of minimum element on each page of 4 dimensional matrix?

1 回表示 (過去 30 日間)
Sajid Sarwar
Sajid Sarwar 2021 年 6 月 9 日
編集済み: KSSV 2021 年 6 月 9 日
I have 4 dimensional vector similar to that shown in attached picture. I want to find position (indices) of minimum on every page separately. For example for 2 dimension we can do like this,
[i, j]=find(A == min(min(A)));
Similar thing i want to do for 4 dimensional vector. Is there any solution using MATLAB?

採用された回答

KSSV
KSSV 2021 年 6 月 9 日
編集済み: KSSV 2021 年 6 月 9 日
You can use the function min to achieve this. Read about it.
% demo data using 3D matrix
A(:,:,1) = [2 4; -2 1];
A(:,:,2) = [9 13; -5 7];
A(:,:,3) = [4 4; 8 -3];
[val,idx] = min(A,[],[1 2],'linear') ; % gives min value and global index
[i,j,k] = ind2sub(size(A),idx) ; % get sub index from global index
idx gives you the global index, you can convert them into sub index using ind2sub. Read about this function.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by