[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Matrix replication column
From: |
Peter Williams |
Subject: |
Re: Matrix replication column |
Date: |
Fri, 4 Apr 2008 12:37:46 -0700 |
User-agent: |
KMail/1.9.7 |
%This is probably a little clumsy, but it works
clear all;
%Enter ANY matrix
A = [1 7 3
2 2 3]
%Enter your desired "multiplier"
H=4
Z=zeros(rows(A),columns(A)*H)
for i = 1:rows(A)
for j = 1:columns(A)
for p=(j-1)*H+1:j*H
Z(i,p)=A(i,j)
end
end
end
On Friday 04 April 2008 11:44:28 am Oscar Bayona Candel wrote:
> Hi all,
>
> I´m using
>
> Z=repmat(1:B,M,1)
>
> so it brings me a matrix whose size is (M,B) incrising each row in one unit
>
> I want to create a new matrix
>
> GG whose size will be (M,H*B)
>
> The first H colums of GG will be the first column of Z, repeated H times.
> The second H columns of GG will be the sencond columns of Z repeated.
>
> An example:
>
> B=3
> M=2
> H=3
>
> so
>
>
> Z=[1 2 3
> 1 2 3];
>
> The code I want to construct will have a result like this....
>
> GG=[1 1 1 2 2 2 3 3 3
> 1 1 1 2 2 2 3 3 3];
>
> I have been trying with kronecker function but I am not able...do you know
> some function similar.
>
> In other context I´ve been able to apply kronecker....its wonderfull¡¡¡ But
> in this context I am not able to advanced at the moment.
>
> If some of you can help me it will be great.
>
> Thanks in advance.
>
>
>
>
> _________________________________________________________________
> MSN Noticias
> http://noticias.msn.es/comunidad.aspx
--
Peter Tucker Williams
Graduate Teaching Fellow
Department of Economics
University of Oregon