Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
rectangular matrix

Subject: rectangular matrix

From: Artur Racu

Date: 11 May, 2010 07:22:03

Message: 1 of 5

hy everybody,

how can help me, i hve a retangular matrix and belove the diagonal i have zeros how can i remove them without removing zeros above the diagonal,

thank you,
Artur

Subject: rectangular matrix

From: Bruno Luong

Date: 11 May, 2010 08:21:04

Message: 2 of 5

"Artur Racu" <arturracu@yahoo.com> wrote in message <hsb0ir$dlj$1@fred.mathworks.com>...
> hy everybody,
>
> how can help me, i hve a retangular matrix and belove the diagonal i have zeros how can i remove them without removing zeros above the diagonal,

help TRIU
help TRIL

Bruno

Subject: rectangular matrix

From: Oleg Komarov

Date: 11 May, 2010 08:22:04

Message: 3 of 5

"Artur Racu"
> hy everybody,
>
> how can help me, i hve a retangular matrix and belove the diagonal i have zeros how can i remove them without removing zeros above the diagonal,
>
> thank you,
> Artur

I suppose you have, for example purposes:
rectM = rand(3,4)
rectM =
          0.35 0.55 0.76 0.57
          0.83 0.92 0.75 0.08
          0.59 0.29 0.38 0.05

Then, creating the index for the elements under the diagonal:
IDXl = logical(tril(ones(size(rectM)),-1))
IDXl =
     0 0 0 0
     1 0 0 0
     1 1 0 0

Finally I don't know what you mean by removing elements...I interpret it as NaNning them out:
rectM(IDXl) = NaN
rectM =
          0.35 0.55 0.76 0.57
           NaN 0.92 0.75 0.08
           NaN NaN 0.38 0.05

Oleg

Subject: rectangular matrix

From: Artur Racu

Date: 11 May, 2010 13:31:22

Message: 4 of 5

"Oleg Komarov" <oleg.komarovRemove.this@hotmail.it> wrote in message <hsb43b$ruc$1@fred.mathworks.com>...
> "Artur Racu"
> > hy everybody,
> >
> > how can help me, i hve a retangular matrix and belove the diagonal i have zeros how can i remove them without removing zeros above the diagonal,
> >
> > thank you,
> > Artur
>
> I suppose you have, for example purposes:
> rectM = rand(3,4)
> rectM =
> 0.35 0.55 0.76 0.57
> 0.83 0.92 0.75 0.08
> 0.59 0.29 0.38 0.05
>
> Then, creating the index for the elements under the diagonal:
> IDXl = logical(tril(ones(size(rectM)),-1))
> IDXl =
> 0 0 0 0
> 1 0 0 0
> 1 1 0 0
>
> Finally I don't know what you mean by removing elements...I interpret it as NaNning them out:
> rectM(IDXl) = NaN
> rectM =
> 0.35 0.55 0.76 0.57
> NaN 0.92 0.75 0.08
> NaN NaN 0.38 0.05
>
> Oleg

thank you,

i found a new solution, i made a loop for extracting the upper part of the matrix,

thanks anyway,

Artur

Subject: rectangular matrix

From: Oleg Komarov

Date: 11 May, 2010 15:02:07

Message: 5 of 5

"Artur Racu" <
> "Oleg Komarov"
> > "Artur Racu"
> > > hy everybody,
> > >
> > > how can help me, i hve a retangular matrix and belove the diagonal i have zeros how can i remove them without removing zeros above the diagonal,
> > >
> > > thank you,
> > > Artur
> >
> > I suppose you have, for example purposes:
> > rectM = rand(3,4)
> > rectM =
> > 0.35 0.55 0.76 0.57
> > 0.83 0.92 0.75 0.08
> > 0.59 0.29 0.38 0.05
> >
> > Then, creating the index for the elements under the diagonal:
> > IDXl = logical(tril(ones(size(rectM)),-1))
> > IDXl =
> > 0 0 0 0
> > 1 0 0 0
> > 1 1 0 0
> >
> > Finally I don't know what you mean by removing elements...I interpret it as NaNning them out:
> > rectM(IDXl) = NaN
> > rectM =
> > 0.35 0.55 0.76 0.57
> > NaN 0.92 0.75 0.08
> > NaN NaN 0.38 0.05
> >
> > Oleg
>
> thank you,
>
> i found a new solution, i made a loop for extracting the upper part of the matrix,
>
> thanks anyway,
>
> Artur
Be aware that looping on big matrices may result significantly slower than using triu or tril.

Oleg

Tags for this Thread

No tags are associated with this thread.

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.

Contact us