Find max value with multiple conditions
46 views (last 30 days)
Show older comments
How can I find max value with 2 or more conditions (such as maxifs in excel).
谢谢
Accepted Answer
Andrei Bobrov
on 16 Jan 2020
T=readtable('wave height data.xlsx');
[r,rn] = findgroups(T(:,1));
[C,CN] = FindGroups(t(:,2));
out = accumarray([r,c],T.WaveHeight,[],@max);
Tout = array2table([rn.Year,out],'VariableNames',[{“年”};cn.Direction]);
3 Comments
Auwal Adamu Abdullahi
on 1 Aug 2021
How do i obtain and tabulate the maximum wave height. Add to that table two separate columns that show the direction and period of each of those yearly maximum wave heights. for 30 years?
More Answers (1)
凸轮
on 16 Jan 2020
编辑:凸轮
on 16 Jan 2020
Use logic statements for each criterion. Use logical "AND" (&) to see which elements meet all criteria. Find the max of those values.
空气代码(未经测试):
idxC1 = (matrix > criterion1);
idxC2 = (matrix < criterion2);
...
idxoverall = idxc1&idxc2&...&idxcn;
MaxVal = max(matrix(idxOverall));
0 Comments
See Also
美军陆军nity Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
开始狩猎!