how to find the largest element if you have an EXTREMELY large data array?

1 回表示 (過去 30 日間)
congcong
congcong 2015 年 8 月 19 日
コメント済み: congcong 2015 年 8 月 19 日
I have a data array contains 195110 elements. Matlab reminds me the data set is too large that I cannot use the max() to find the largest element. PS: The only way I can think of is to paste it to excel and find the largest element. But for too many data sets, manually doing this becomes impossible. Please help! Thanks!

採用された回答

Sean de Wolski
Sean de Wolski 2015 年 8 月 19 日
Ahhh!
It has nothing to do with size, it has to do with comma separated expansion
When you run:
cluster_tot{:,3}
It extracts every cell in that column. Each cell is then passed into max() as it's own variable. So for example:
x = num2cell(rand(5,1))
max(x{:})
Is equivalent to
max(x{1},x{2},x{3},x{4},x{5})
Max doesn't work like this. If the cells are all the same size, you should be able to horizontally or vertically concatenate them in order to take the max:
max([cluster_tot{:,3}])
Which would first combine them into one input and then take the max of it.
If they're not the same size, you'll need to use cellfun first.
max(cellfun(@(x)max(x(:)),cluster_tot(:,3)))
Note the use of () instead of {} because I want cellfun to operate on the cells not the contents in them.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by