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

조회 수: 1 (최근 30일)
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 CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by