I have a 4X4 struct. Each position (row,column) has a title and an [1X82] array. I wish to compare these arrays column wise. First, I want to find the max value within each array and then compare these max values to get the 'final max val'. Ultimately, I want the title of the index which has the 'final max val'. How can this be done?
I have attached my script for finding the max within the arrays and saving them in another struct.
for row=1:size(W_temp,1)
for column=1:size(W_temp,2)
Max(row,column).data=max(abs(W_temp(row,column).data));
Max(row,column).title=W_temp(row,column).title;
end
end

2 件のコメント

KSSV
KSSV 2021 年 3 月 18 日
Read about max function.
shekhar narayanan
shekhar narayanan 2021 年 3 月 18 日
編集済み: shekhar narayanan 2021 年 3 月 18 日
Ah, I see what you mean. I fixed it using extractfield and the indexing code for max. Thank you.
A=extractfield(Max(row,:),'data');
[M,I]=max(A,[],'linear');
Store=[Store;W_temp(row,I)];

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

 採用された回答

Matt J
Matt J 2021 年 3 月 18 日

1 投票

[total_max,idx]=max( max( vertcat(Max(:).data) ,[],2) );
Max(idx).title

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

タグ

質問済み:

2021 年 3 月 18 日

回答済み:

2021 年 3 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by