how to find the largest element if you have an EXTREMELY large data array?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
congcong
am 19 Aug. 2015
Kommentiert: congcong
am 19 Aug. 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!
0 Kommentare
Akzeptierte Antwort
Sean de Wolski
am 19 Aug. 2015
Ahhh!
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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!