help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Matrix replication column


From: John W. Eaton
Subject: Matrix replication column
Date: Fri, 04 Apr 2008 15:42:53 -0400

On  4-Apr-2008, 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.

Try

  B = 3;
  M = 2;
  H = 3;
  Z = repmat (1:B, M, 1)
  GG = kron (Z, ones (1, 3))

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]