From: sarrah on
"sarrah " <gto_girlz83(a)yahoo.com> wrote in message <hs6764$lvb$1(a)fred.mathworks.com>...
> "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <hs65sr$c9$1(a)fred.mathworks.com>...
> > "sarrah " <gto_girlz83(a)yahoo.com> wrote in message <hs63r8$j9i$1(a)fred.mathworks.com>...
> > > "Mongkut Piantanakulchai" <mongkutp.remove.this(a)gmail.com> wrote in message <hs45g9$rok$1(a)fred.mathworks.com>...
> > > > For the first one, try this
> > > >
> > > > B=[1 0];
> > > > A=blkdiag(B,B,B,B,B,B,B,B);
> > > >
> > > > Mongkut
> > >
> > > Thanks Mongkut.It does help but I have to repeat the B for 8 times. Is there any other way for making it more flexible especially for larger size?
> > >
> >
> > A = repmat({B},1,888);
> > A = blkdiag(A{:});
> >
> > Better yet is to make the result a sparse matrix.
> >
> > A = repmat({sparse(B)},1,888);
> > A = blkdiag(A{:});
> >
> > whos A
> > Name Size Bytes Class Attributes
> > A 888x1776 28424 double sparse
> >
> > John
> ----------------------------------------
> Thanks a lot John!!
> How about I still want to use the same vector B[1 0] creates this D matrix as below:
> D=
> [1 0 0 0 0 0 0 0;
> 0 1 0 0 0 0 0 0;
> 0 0 0 0 1 0 0 0;
> 0 0 0 0 0 1 0 0];
>
> I don't think we can use the blkdiag function again. Any idea?

---Add information to the above question. The problem now is to remove the multiple row alternately
From: sarrah on
"sarrah " <gto_girlz83(a)yahoo.com> wrote in message <hs6764$lvb$1(a)fred.mathworks.com>...
> "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <hs65sr$c9$1(a)fred.mathworks.com>...
> > "sarrah " <gto_girlz83(a)yahoo.com> wrote in message <hs63r8$j9i$1(a)fred.mathworks.com>...
> > > "Mongkut Piantanakulchai" <mongkutp.remove.this(a)gmail.com> wrote in message <hs45g9$rok$1(a)fred.mathworks.com>...
> > > > For the first one, try this
> > > >
> > > > B=[1 0];
> > > > A=blkdiag(B,B,B,B,B,B,B,B);
> > > >
> > > > Mongkut
> > >
> > > Thanks Mongkut.It does help but I have to repeat the B for 8 times. Is there any other way for making it more flexible especially for larger size?
> > >
> >
> > A = repmat({B},1,888);
> > A = blkdiag(A{:});
> >
> > Better yet is to make the result a sparse matrix.
> >
> > A = repmat({sparse(B)},1,888);
> > A = blkdiag(A{:});
> >
> > whos A
> > Name Size Bytes Class Attributes
> > A 888x1776 28424 double sparse
> >
> > John
> ----------------------------------------
> Thanks a lot John!!
> How about I still want to use the same vector B[1 0] creates this D matrix as below:
> D=
> [1 0 0 0 0 0 0 0;
> 0 1 0 0 0 0 0 0;
> 0 0 0 0 1 0 0 0;
> 0 0 0 0 0 1 0 0];
>
> I don't think we can use the blkdiag function again. Any idea?
---------
I have the solution for the above question but it is not practical for larger matrix.

D=eye(16);
dToRemove = [3,4,7,8,11,12,15,16];
D(dToRemove,:) = [];

Let say the D matrix has bigger size, eye(200) and I don't want to repeat listing all the entries to be remove as above. We can see the pattern of listing from dToRemove variable. Any better suggestion? Thanks in advance.
From: John D'Errico on
"sarrah " <gto_girlz83(a)yahoo.com> wrote in message <hs6764$lvb$1(a)fred.mathworks.com>...

> How about I still want to use the same vector B[1 0] creates this D matrix as below:
> D=
> [1 0 0 0 0 0 0 0;
> 0 1 0 0 0 0 0 0;
> 0 0 0 0 1 0 0 0;
> 0 0 0 0 0 1 0 0];
>
> I don't think we can use the blkdiag function again. Any idea?

You need to define how that vector B will generate that
array. The crystal ball is cloudy, making it impossible
for me to read your mind.

John
From: sarrah on
"John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <hs6evg$5j0$1(a)fred.mathworks.com>...
> "sarrah " <gto_girlz83(a)yahoo.com> wrote in message <hs6764$lvb$1(a)fred.mathworks.com>...
>
> > How about I still want to use the same vector B[1 0] creates this D matrix as below:
> > D=
> > [1 0 0 0 0 0 0 0;
> > 0 1 0 0 0 0 0 0;
> > 0 0 0 0 1 0 0 0;
> > 0 0 0 0 0 1 0 0];
> >
> > I don't think we can use the blkdiag function again. Any idea?
>
> You need to define how that vector B will generate that
> array. The crystal ball is cloudy, making it impossible
> for me to read your mind.
>
> John
----------------------------------------
Sorry to confuse you. Lets forget about the vector B and I already constructed that matrix D as I mentioned above but how can I improve it without listing all the columns that I want to delete?

D=eye(16);
rowToRemove = [3,4,7,8,11,12,15,16];
D(rowToRemove,:) = [];
D=[4x8]; %output

Let say the D matrix has bigger size, eye(200) and I don't want to repeat listing all the entries to be remove. We can see the pattern of listing from dToRemove variable. Any better suggestion? Thanks in advance.
From: John D'Errico on
"sarrah " <gto_girlz83(a)yahoo.com> wrote in message <hs6fpo$qnp$1(a)fred.mathworks.com>...
> "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <hs6evg$5j0$1(a)fred.mathworks.com>...
> > "sarrah " <gto_girlz83(a)yahoo.com> wrote in message <hs6764$lvb$1(a)fred.mathworks.com>...
> >
> > > How about I still want to use the same vector B[1 0] creates this D matrix as below:
> > > D=
> > > [1 0 0 0 0 0 0 0;
> > > 0 1 0 0 0 0 0 0;
> > > 0 0 0 0 1 0 0 0;
> > > 0 0 0 0 0 1 0 0];
> > >
> > > I don't think we can use the blkdiag function again. Any idea?
> >
> > You need to define how that vector B will generate that
> > array. The crystal ball is cloudy, making it impossible
> > for me to read your mind.
> >
> > John
> ----------------------------------------
> Sorry to confuse you. Lets forget about the vector B and I already constructed that matrix D as I mentioned above but how can I improve it without listing all the columns that I want to delete?
>
> D=eye(16);
> rowToRemove = [3,4,7,8,11,12,15,16];
> D(rowToRemove,:) = [];
> D=[4x8]; %output
>
> Let say the D matrix has bigger size, eye(200) and I don't want to repeat listing all the entries to be remove. We can see the pattern of listing from dToRemove variable. Any better suggestion? Thanks in advance.

I don't see it as difficult to remove the unwanted
columns. Do it in exactly those two steps. By
trying to combine it into one, you create a problem
that is more complex than it needs to be. While
you COULD do it all with an appropriate call to
sparse, constructing the arguments to sparse will
take more work than just doing it the direct way.

You have two things to be done. Do them one at a
time.

John
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: SVDS inconsistency
Next: fitting model + plotting