フィルターのクリア

How to vectorize for loop on cell array(with additional indexing)

5 ビュー (過去 30 日間)
AKSHAY PUJARI
AKSHAY PUJARI 2020 年 5 月 8 日
コメント済み: AKSHAY PUJARI 2020 年 5 月 8 日
I have the below for loop that needs to be vectorized.
I am unable to vectorize effectively as I have to use for loop(to obtain 'solution ') even after using cell fun to obtain the max value initially.
CuMu=[{'a'},{[100 1;1,1;50 2]};{'b'},{[150 1; 50 2]};{'c'},{[200 1;3,3; 50 2]};{'d'},{[250 1;1,1;1,1; 50 2]};{'e'},{[300 1; 50 2]}];
for k=1:5
Max(k,:)=max(CuMu{k,2}(:,1));
end
solution=max(Max);
Objective:To improve the performace through vectorization
Thanks.

採用された回答

Walter Roberson
Walter Roberson 2020 年 5 月 8 日
solution = max( cellfun(@(CUMU) max(CUMU(:,1)), CuMu(:,2)) )

その他の回答 (0 件)

カテゴリ

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