Thread Subject: matrix operation

Subject: matrix operation

From: John Gar

Date: 8 Feb, 2010 12:38:03

Message: 1 of 4

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,

   

Subject: matrix operation

From: Oleg Komarov

Date: 8 Feb, 2010 14:36:03

Message: 2 of 4

"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

Subject: matrix operation

From: John Gar

Date: 9 Feb, 2010 10:45:05

Message: 3 of 4

"Oleg Komarov" <oleg.komarovRemove.this@hotmail.it> wrote in message <hkp7gj$cke$1@fred.mathworks.com>...
> "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??

Subject: matrix operation

From: Oleg Komarov

Date: 9 Feb, 2010 12:28:04

Message: 4 of 4

"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

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
flag John Gar 9 Feb, 2010 05:49:11
matrix John Gar 8 Feb, 2010 07:39:05
rssFeed for this Thread

Contact us at files@mathworks.com