🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.soft-sys.matlab
Article #106

Re: Combining vectors

#106
From: Joe Barsugli
Date: Wed, 27 Jan 1993 01:51
35 lines
1743 bytes
In article <1k5hf2INNlgs@shelley.u.washington.edu>
phantom@stein2.u.washington.edu (The Phantom) writes in response to:

>   reese@vax.oxford.ac.uk, who wrote:
>
>   >I want to take two vectors and combine them, e.g.
>   >[ a b c d e]  and [ f g h i j ] 
>   >become  [ a f b g c h d i e j ]
>   >
>
>   say a=[ a b c d e ] and b=[ f g h i j ] -- an easy way to do this would be
>   using ...
>
>   len=length(a);			%assuming length(a), length(b) are equal
>   FOR count=1:len,
>	   c((count*2)-1)=a(count);
>	   c((count*2)=b(count);
>   END
>
>   that seems to work, anyway. just work with the commands for picking out 
>   certain matrix spots and FOR loops, and you should be able to comprise 
>   something that works both ways.
>
>   mt


How about a method which avoids the FOR loop:

c = [a;b];c = c(:)'  to go from a = [a b c ...] b = [f g h  ...] to 
                     c = [a f b g c h ...]

and a = c(1:2:length(c));b = c(2:2:length(c)); to unscramble.


Joe (joeb@atmos.washington.edu)
Technical Details
Message-ID: <JOEB.93Jan27015111@eos1.atmos.washington.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!sgiblab!darwin.sura.net!bogus.sura.net!howland.reston.ans.net!usc!rpi!usenet.coe.montana.edu!news.u.washington.edu!atmos.washington.edu!joeb
References: <1993Jan26.182616.11550@vax.oxford.ac.uk> <1k5hf2INNlgs@shelley.u.washington.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!sgiblab!darwin.sura.net!bogus.sura.net!howland.reston.ans.net!usc!rpi!usenet.coe.montana.edu!news.u.washington.edu!atmos.washington.edu!joeb
From: joeb@atmos.washington.edu (Joe Barsugli)
Newsgroups: comp.soft-sys.matlab
Subject: Re: Combining vectors
Date: 27 Jan 93 01:51:11
Organization: Dept. of Atmospheric Sciences, University of Washington
Lines: 37
Distribution: world
Message-ID: <JOEB.93Jan27015111@eos1.atmos.washington.edu>
References: <1993Jan26.182616.11550@vax.oxford.ac.uk>
 <1k5hf2INNlgs@shelley.u.washington.edu>
NNTP-Posting-Host: eos1.atmos.washington.edu
In-reply-to: phantom@stein2.u.washington.edu's message of 27 Jan 1993 08:34:42 GMT