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

3 vues (au cours des 30 derniers jours)
congcong
congcong le 19 Août 2015
Commenté : congcong le 19 Août 2015
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!

Réponse acceptée

Sean de Wolski
Sean de Wolski le 19 Août 2015
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.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by