find and store the index value of maximum or minimum value of cell array

4 ビュー (過去 30 日間)
neha mehani
neha mehani 2022 年 10 月 3 日
編集済み: Davide Masiello 2022 年 10 月 3 日
i have cell of size 613x1 and each cell has 200x1 column in it . i want to find out the index location of maximum and minimum of each column in cell and store it in different vector. further i want to split the cell based on these index location.

回答 (2 件)

Simon Chan
Simon Chan 2022 年 10 月 3 日
[~,idxMax]=cellfun(@max,yourCell); % Index for maximum
[~,idxMin]=cellfun(@min,yourCell); % Index for minimum

Davide Masiello
Davide Masiello 2022 年 10 月 3 日
編集済み: Davide Masiello 2022 年 10 月 3 日
Example
for row = 1:613
yourcellarray(row,1) = {randi(100,200,1)};
end
yourcellarray
yourcellarray = 613×1 cell array
{200×1 double} {200×1 double} {200×1 double} {200×1 double} {200×1 double} {200×1 double} {200×1 double} {200×1 double} {200×1 double} {200×1 double} {200×1 double} {200×1 double} {200×1 double} {200×1 double} {200×1 double} {200×1 double}
yourcellarray{1}
ans = 200×1
49 86 95 78 37 36 99 4 67 13
Above is just an example of the type of cell array you have described. Now, to find the index of the maximum and minimum for each cell, you just need to do
[~,idxMax] = cellfun(@max,yourcellarray)
idxMax = 613×1
7 93 4 40 55 41 58 50 106 28
[~,idxMin] = cellfun(@min,yourcellarray)
idxMin = 613×1
22 45 50 62 167 71 57 170 17 91
Regarding splitting the cell array based on the index of the maximum you need to give more info.

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by