find 4d matrix positions

12 ビュー (過去 30 日間)
john_arle
john_arle 2019 年 11 月 5 日
編集済み: Stephen23 2019 年 11 月 5 日
Hello!
i want to searcha 4d matrix to find all indeces relative to non yero elements.
<i would like to store those indeces in n times 4 matrix,
where n is the number of points found.
I tried with ind2sub but it was useless.

採用された回答

Stephen23
Stephen23 2019 年 11 月 5 日
編集済み: Stephen23 2019 年 11 月 5 日
"I tried with ind2sub but it was useless."
It worked for me. First lets define some fake data:
>> A = zeros(5,4,3,2);
>> A(5,3,2,1) = 1;
>> A(3,1,1,2) = 1;
then get the indices of non-zero array elements:
>> [R,C,P,Q] = ind2sub(size(A),find(A));
>> M = [R,C,P,Q]
M =
5 3 2 1
3 1 1 2

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by