Remove a row based on its value

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)

 采纳的回答

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,:)=[];

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品

版本

R2021b

标签

Community Treasure Hunt

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

Start Hunting!

Translated by