|
"John Gar" <
> "Oleg Komarov"
> > "John Gar"
> > > Hello all,
> > >
> > > I need some help in a matrix operation.
> > > I have a big matrix with a large number of zero rows, and other rows with some numbers. For example an [180 200], when the first 100 rows are zeros, after 5 rows with numbers, again 30 zero rows, 25 numbers rows and 20 zeros rows.
> > >
> > > What I want is to take out from the big matrix to another small matrix - the 5 rows with numbers, and after that to a second small matrix the 25 rows with number.
> > > (sometimes it can be more than two small matrix, depends on the original signal.)
> > >
> > > Some ideas? Help?
> > >
> > > thanx,
> > >
> > Why don't you just remove those rows with all zeros?
> > You may find useful the "matrix indexing" chapter in the online docs.
> > Ex:
> > A = [0,0; 0,0; 1,1];
> > A(all(A == 0,2) ,:) = [];
> >
> > Oleg
>
> Hi Oleg, thanks for answering.
>
> The problem is, that if I remove all the zeros, how I can know the limit between each number part (from the matrix). In my case, each number part is a word sampled, and I want to divide this words..
> Can I insert some flag to know when each part is finished??
A = [0,0; 0,0; 1,1];
% Add the line number
A = [(1:size(A,1)).' A];
% Remove every row whenever the columns from 2 to end are 0
A(all(A(:,2:end) == 0,2) ,:) = [];
Oleg
|