COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Creating copy of columns in Matrix

• Email
• Follow

```This sounds stupid may be its a long hour work which make my mind stop working ! But what is easiest way to create a copies of a vector in a matrix form !

My vector is t=[1 2 3 4 5 6]

now i want t to be matrix of size ( 6 by 300) ..which means copies of my vector t in a matrix form !

Thanks
```
 0

See related articles to this posting

```"kk KKsingh" <akikumar1983@gmail.com> wrote in message <i3ol26\$rk4\$1@fred.mathworks.com>...
> This sounds stupid may be its a long hour work which make my mind stop working ! But what is easiest way to create a copies of a vector in a matrix form !
>
> My vector is t=[1 2 3 4 5 6]
>
> now i want t to be matrix of size ( 6 by 300) ..which means copies of my vector t in a matrix form !
>
> Thanks

a hint:

help repmat;
% eg,
v=1:3;
r=repmat(v,4,1)
%{
%    r =
1     2     3
1     2     3
1     2     3
1     2     3
%}

us
```
 1

```Dear kk,
> But what is easiest way to create a copies of a vector in a matrix form !
> My vector is t=[1 2 3 4 5 6]
> now i want t to be matrix of size ( 6 by 300) ..which means copies of my vector t in a matrix form !

Beside REPMAT you could create the matrix manually also:
t = 1:6;
M = t(ones(1, 600), :);
This is done in REPMAT also, so you could avoid the overhead.
Please decide, which is "easiest" way.

Kind regards, Jan
```
 0