Cell Array Search and indexing

6 ビュー (過去 30 日間)
Zaharaddeen Hussaini
Zaharaddeen Hussaini 2020 年 11 月 30 日
回答済み: Zaharaddeen Hussaini 2020 年 11 月 30 日
Hello,
Please how do I find the maximum column in a cell array and assign the index position to other variables?
i = 1:5
j = 1:8
AllOutput{1,i}{1,j};
max([AllOutput{1,i}{1,2}],[],2) % Tried this but cannot seem to get it to work through all the i matrix
DT_values = AllOutput{1,i}{1,2}; % find the maximum column from all the ith array
maximum = ((max(DT_values,[],2)));
[M,I]=find(DT_values==maximum);
Dr_opt = AllOutput{1,i}{1,3};
Output= Dr_opt(I); %Assign other variables to the same index position as above
  1 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 11 月 30 日
Can you describe the question with a sample example?

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

回答 (1 件)

Zaharaddeen Hussaini
Zaharaddeen Hussaini 2020 年 11 月 30 日
Thanks for responding to this.I am not sure I can provide much as I am really completely stuck. But here is an example I hope it helps to undertansd the problem
A={ {num2cell(rand(3,4)) num2cell(rand(3,4)) num2cell(rand(3,4))} {num2cell(rand(3,4)) num2cell(rand(3,4)) num2cell(rand(3,4)) }}
for i = 1:length(A)
B = A{1,i}{1,2};
C = A{1,i}{1,1};
B_Saved{i} = B;
C_Saved{i} = C;
end
% How do I find the maximum column in all of B_Saved.
% Secondly, how to equate the postion of max xolumn in B_Saved to C_Saved

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by