From: AMK on
Can someone point to a more efficient method to obtain a multi column matrix of a repeated single column?

v = data(:,4);
v = [v v v v v v];
From: dpb on
AMK wrote:
> Can someone point to a more efficient method to obtain a multi column matrix of a repeated single column?
>
> v = data(:,4);
> v = [v v v v v v];

doc repmat; % for one

--
From: Matt J on
AMK <kennaster(a)gmail.com> wrote in message <1871381264.317648.1267728391027.JavaMail.root(a)gallium.mathforum.org>...
> Can someone point to a more efficient method to obtain a multi column matrix of a repeated single column?
>
> v = data(:,4);
> v = [v v v v v v];
================

Are you sure you need this? These days, with bsxfun(), this kind of replication is rarely necessary.
From: us on
AMK <kennaster(a)gmail.com> wrote in message <1871381264.317648.1267728391027.JavaMail.root(a)gallium.mathforum.org>...
> Can someone point to a more efficient method to obtain a multi column matrix of a repeated single column?
>
> v = data(:,4);
> v = [v v v v v v];

one of the other solutions

v=(1:3).';
v=v(:,ones(1,5))
%{
% v =
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
%}

us
From: AMK on
Great! It actually might not be necessary, but I always find myself thinking I need to replicate a column like this.

Thanks!