Find max value with multiple conditions

조회 수: 39 (최근 30일)
Anita Fitriani
Anita Fitriani 2020년 1월 15일
댓글: Auwal Adamu Abdullahi 2021년 8월 1일
How can I find max value with 2 or more conditions (such as maxifs in excel).
Thanks before
  댓글 수: 6
Andrei Bobrov
Andrei Bobrov 2020년 1월 16일
Please attach small part of your excel-file or data table as MATLAB variable - 'table' in mat -file.
Anita Fitriani
Anita Fitriani 2020년 1월 16일
This is small part of my wave height data

댓글을 달려면 로그인하십시오.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2020년 1월 16일
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',[{'Year'};cn.Direction]);
  댓글 수: 3
Andrei Bobrov
Andrei Bobrov 2020년 1월 17일
Anita! If my answer solved your problem, then please accept it.
Auwal Adamu Abdullahi
Auwal Adamu Abdullahi 2021년 8월 1일
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?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

CAM
CAM 2020년 1월 16일
편집: CAM 2020년 1월 16일
Use logic statements for each criterion. Use logical "AND" (&) to see which elements meet all criteria. Find the max of those values.
Air Code (untested):
idxC1 = (matrix > criterion1);
idxC2 = (matrix < criterion2);
...
idxOverall = idxC1 & idxC2 & ... & idxCn;
MaxVal = max(matrix(idxOverall));

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by