Remove a row based on its value

4 views (last 30 days)
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)

Accepted Answer

David Hill
David Hill on 7 Apr 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,:)=[];

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!