From: Robert Barrie on 22 Feb 2010 01:19 Hi All, I have a column vector of numbers that I would like to extrapolate by "doubling up": e.g. turn 2 4 6 8 into: 2 2 4 4 6 6 8 8 any ideas on an easy vectorised way to do this? TIA, Rob
From: Matt J on 22 Feb 2010 01:45 v=repmat([2; 4; 6; 8].',2,1); v=v(:)
From: James Tursa on 22 Feb 2010 01:46 "Robert Barrie" <askme(a)ifuwant.com> wrote in message <hlt7kp$rut$1(a)fred.mathworks.com>... > Hi All, > > I have a column vector of numbers that I would like to extrapolate by "doubling up": > > e.g. turn > 2 > 4 > 6 > 8 > > into: > 2 > 2 > 4 > 4 > 6 > 6 > 8 > 8 > > any ideas on an easy vectorised way to do this? > > TIA, > > Rob x = [2;4;6;8]; y = [x x]'; y = y(:); James Tursa
From: Robert Barrie on 22 Feb 2010 02:02 Thanks, Though both of those options worked for x =[2;4;6;8], they didn't seem to work for x = 2:2:8??? (they were doubled but on top of each other, not 'sorted'). (the first way has [2;4;6;8] in the watch window, the 2nd has <4x1 double>) any thoughts? thx
From: James Tursa on 22 Feb 2010 02:23 "Robert Barrie" <askme(a)ifuwant.com> wrote in message <hlta5d$p7g$1(a)fred.mathworks.com>... > Thanks, > > Though both of those options worked for x =[2;4;6;8], they didn't seem to work for x = 2:2:8??? (they were doubled but on top of each other, not 'sorted'). > > (the first way has [2;4;6;8] in the watch window, the 2nd has <4x1 double>) > > any thoughts? > > thx You specifically said "column" vector in your original post. x = 2:2:8 is not a column vector, it is a row vector. For row vectors you can use: x = 2:2:8; y = [x;x]; y = y(:); James Tursa
|
Next
|
Last
Pages: 1 2 Prev: Generalized Eigen Vector problem Next: Setting axis limits on a compass plot |