matlab - specific column [Remove elements up to last zero element, then remove elements from first zero element to the end] -
this specific question. have m*3 matrix. first column contains m set of elements. may follow this.
0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0
my interest 1s , corresponding other column values. can remove zeros new set of matrix 1s, may follow this:
1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1
when situation above want disregard 1s in beginning , remove elements in m*3 matrix first 1, when reaches second start of zeros in column can remove values end of column. (so 13*3 matrix).
i'm doing in matlab. thank :)
let's call matrix a:
firstcol = a(:, 1); indices = find(firstcol); check = find(diff(indices) ~= 1); if (isempty(check) ) afinal = a(indices, :); else indices2 = indices(check(1)+1:1:check(2)); afinal = a(indices2, :); end
afinal should output you're looking for.
Comments
Post a Comment