How to pull out rows with a unique value in a specified column?

6 visualizaciones (últimos 30 días)
I have a matrix variable called 'summed' which is 1330 x 2.
I want to pull out every row of 'summed' that has a unique value in the second column, and store these in a new variable, called 'uniqueVals'
I tried the following line of code:
uniqueVals = summed(:,2) == unique;
Which didn't work, and I am unsure how I should go about doing this?

Respuesta aceptada

Alan Weiss
Alan Weiss el 24 de Oct. de 2017
Perhaps the following works:
[C,ia] = unique(summed(:,2));
uniqueVals = summed(ia,:);
Alan Weiss
MATLAB mathematical toolbox documentation

Más respuestas (1)

Louisa Thomas
Louisa Thomas el 24 de Oct. de 2017
the values in summed are integers, and I'm using MATLAB R2015b

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by