# Find max value with multiple conditions

25 visualizzazioni (ultimi 30 giorni)
Anita Fitriani il 15 Gen 2020
How can I find max value with 2 or more conditions (such as maxifs in excel).
Thanks before
##### 6 CommentiMostra 4 commenti meno recentiNascondi 4 commenti meno recenti
Andrei Bobrov il 16 Gen 2020
Please attach small part of your excel-file or data table as MATLAB variable - 'table' in mat -file.
Anita Fitriani il 16 Gen 2020
This is small part of my wave height data

Accedi per commentare.

### Risposta accettata

Andrei Bobrov il 16 Gen 2020
[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 CommentiMostra 1 commento meno recenteNascondi 1 commento meno recente
Andrei Bobrov il 17 Gen 2020
Auwal Adamu Abdullahi il 1 Ago 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?

Accedi per commentare.

### Più risposte (1)

CAM il 16 Gen 2020
Modificato: CAM il 16 Gen 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));
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Tables in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by