Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!feeder.erje.net!us.feeder.erje.net!news.stack.nl!aioe.org!.POSTED!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: doubts in matlab for combining two vectors
Date: Thu, 20 Dec 2012 01:13:22 -0600
Organization: Aioe.org NNTP Server
Lines: 28
Message-ID: <kaudql$4p4$1@speranza.aioe.org>
References: <kauahd$qj5$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: 2CibzTqnux2ggoH9QofcGw.user.speranza.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0
X-Notice: Filtered by postfilter v. 0.8.2
Xref: news.mathworks.com comp.soft-sys.matlab:785119

On 12/20/2012 12:17 AM, Shobana wrote:
> hai friends..
>
> I want to merge two vectors like in the below specified manner
> for example:
> a= [1 , 2....n1]; b = [3 , 4.......n2]
> then 'c' should be like this c = [1 3 2 4 .........n1,n2]
> i tried like this c = [a,b] but this is not working
> here the value of n1 and n2 will be known at the run time only.
>

may be:

----------------------
N = 4;
A = [1 2 3 4];
B = [3 4 5 6];
C = zeros(1,2*N);

C(1:2:2*N-1) = A;
C(2:2:2*N)   = B
--------------------

C =
      1     3     2     4     3     5     4     6