Remove a row based on its value

4 visualizaciones (últimos 30 días)
Daniel Gaggini
Daniel Gaggini el 7 de Abr. de 2022
Comentada: Daniel Gaggini el 7 de Abr. de 2022
Hello, I want to remove any rows where there is a 0 in column H.
For example if I have a row:
X Y H
[1, 1, 0]
I want to delete this row completly.
This is the code I have so far, but all it does is transpose the my three columns into one row matrix, and does not delete any rows.
X = [1:10]'
Y = [1:10]'
H = [1, 0, 0 , 0, 2, 3, 4, 0 , 0, 4]'
Location = [X,Y,H]
Remove = find(Location(:,3)<1);
Location(Remove)=[];
Does any one have any ideas what I am doing wrong?
(The X,Y,H values are random matrices I have added for context, my real data set is a lot larger)

Respuesta aceptada

David Hill
David Hill el 7 de Abr. de 2022
X = [1:10]'
Y = [1:10]'
H = [1, 0, 0 , 0, 2, 3, 4, 0 , 0, 4]'
Location = [X,Y,H];
Location(Location(:,3)<1,:)=[];

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by