I have three columns containing data. I want to isolate particular data depending on the third column and find the maximum values on the second column for each case of the isolated data from the third column.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have a matrix with the following form:
A = [1 2 3; 2 2 6; 0 1 3; 0 4 3]
I want for each unique case from the third column, to find the maximum values on the first and the second columns.
0 Commenti
Risposte (1)
Michael Madelaire
il 26 Ott 2017
Hi, hope this works.
The first column shows the max in the first column.
The second column shows the max in the second column.
The third column shows the unique values in AA.
A = [1 2 3; 2 2 6; 0 1 3; 0 4 3];
[values, tag, places] = unique(A(:, 3));
AA = zeros(length(values), 3);
AA(:, 3) = values;
for i = 1:length(values)
AA(i, 1) = max(A(places == tag(i), 1));
AA(i, 2) = max(A(places == tag(i), 2));
end
0 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!