如何得到361x91数组中重复最大值的位置
6 views (last 30 days)
Show older comments
最大值是两个重复的值,要得到两个的位置
0 Comments
Accepted Answer
Dyuman Joshi
on 8 May 2024
%Sample data
mat = magic(4);
mat = [mat; 1 4 9 16]
%Get the maximum value
val = max(mat, [], 'all')
%% Find the indices of all occurences of the max value
%Linear indices
idx = find(mat==val)
%Subscript indices
[r,c] = find(mat==val)
Note - Use tolerance to compare for floating point values.
0 Comments
More Answers (0)
See Also
Categories
Find more on Big Data Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!