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!
0 个评论
采纳的回答
Sean de Wolski
2015-8-19
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!