matlab - Delete Rows from matrix -
this question has answer here:
- remove rows of matrix in matlab 1 answer
i have vector x (786432*1) , t(786432*1).
i want delete rows x have value 2 , want delete same(corresponding)rows of t -(for example delete x(1,1) , t(1,1)) no important t values. confusing loop (index)
> [r c]=find(x==2);
how find same r , c in vector t?
how implement in matlab? please 1 can help!
you got how find indices remove:
idxs = find(x==2);
you can remove element @ indices with:
x(idxs) = []; t(idxs) = [];
example:
>> x=randi(10,1,7); >> t=randi(10,1,7); >> x x = 10 3 2 2 1 5 5 >> t t = 6 9 3 4 2 10 7 >> idxs = find(x==2) idxs = 3 4 >> x(idxs)=[] x = 10 3 1 5 5 >> t(idxs)=[] t = 6 9 2 10 7 >>
Comments
Post a Comment