Effacer les filtres
Effacer les filtres

Find max value with multiple conditions

42 vues (au cours des 30 derniers jours)
Anita Fitriani
Anita Fitriani le 15 Jan 2020
How can I find max value with 2 or more conditions (such as maxifs in excel).
Thanks before
  6 commentaires
Andrei Bobrov
Andrei Bobrov le 16 Jan 2020
Please attach small part of your excel-file or data table as MATLAB variable - 'table' in mat -file.
Anita Fitriani
Anita Fitriani le 16 Jan 2020
This is small part of my wave height data

Connectez-vous pour commenter.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 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',[{'Year'};cn.Direction]);
  3 commentaires
Andrei Bobrov
Andrei Bobrov le 17 Jan 2020
Anita! If my answer solved your problem, then please accept it.
Auwal Adamu Abdullahi
Auwal Adamu Abdullahi le 1 Août 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?

Connectez-vous pour commenter.

Plus de réponses (1)

CAM
CAM le 16 Jan 2020
Modifié(e) : CAM le 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.
Air Code (untested):
idxC1 = (matrix > criterion1);
idxC2 = (matrix < criterion2);
...
idxOverall = idxC1 & idxC2 & ... & idxCn;
MaxVal = max(matrix(idxOverall));

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by