I am getting the error "Matrix index is out of range for deletion". What I am trying to accomplish is: where ever there is a 0 in f…..i want to delete that row number from g.
g =
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
f =
1 1 0 1 0
>> for j= 1:numel(f)
if f(j)==0
g(j,:)=[]
end
end
g =
1 1 1 1
2 2 2 2
4 4 4 4
5 5 5 5
Matrix index is out of range for deletion.
The output should be g without the 3rd and 5th row.
g=[1 1 1 1; 2 2 2 2; 4 4 4 4]
Best Answer