Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Interleave every 2 values
Date: Thu, 19 Feb 2009 08:43:02 +0000 (UTC)
Organization: Erasmus MC
Lines: 21
Message-ID: <gnj62l$2vc$1@fred.mathworks.com>
References: <gnidd9$232$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1235032982 3052 172.30.248.38 (19 Feb 2009 08:43:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 19 Feb 2009 08:43:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 870065
Xref: news.mathworks.com comp.soft-sys.matlab:519345


"Sylvie " <sylpel@yorku.ca> wrote in message <gnidd9$232$1@fred.mathworks.com>...
> Hello,
> 
> s=[linspace(0,3,22)];
> 
> I would like to interleave every 2 numbers: 
> [s(1),s(3),s(2),s(4)...s(22)]
> 
> Any suggestion
> 
> Sylvie

So you want numbers to repeat, as in [s1, s3, s2, s4, s3, s5, s4, s6 ... s22]

s = 1:8
s2 = reshape([s(1:end-2) ; s(3:end)],1,[])

If this is not what you want, try again ...

hth
Jos