home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.soft-sys.matlab
- Path: sparky!uunet!news.univie.ac.at!scsing.switch.ch!univ-lyon1.fr!ghost.dsi.unimi.it!rpi!usc!howland.reston.ans.net!spool.mu.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!sample.eng.ohio-state.edu!dosequis!dilsavor
- From: dilsavor@dosequis.eng.ohio-state.edu (Ron L. Dilsavor)
- Subject: Re: Combining vectors
- Message-ID: <1993Jan27.155815.23225@ee.eng.ohio-state.edu>
- Sender: news@ee.eng.ohio-state.edu
- Organization: The Ohio State University Dept of Electrical Engineering
- References: <1993Jan26.182616.11550@vax.oxford.ac.uk> <1k5hf2INNlgs@shelley.u.washington.edu>
- Date: Wed, 27 Jan 1993 15:58:15 GMT
- Lines: 33
-
- In article <1k5hf2INNlgs@shelley.u.washington.edu> phantom@stein2.u.washington.edu (The Phantom) writes:
- >In article <1993Jan26.182616.11550@vax.oxford.ac.uk> reese@vax.oxford.ac.uk writes:
- >>
- >>
- >>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
- >
-
- Try to avoid using slow FOR loops if you can.
- Here is a neat way which is faster
-
- c(2:2:2*length(b))=b;
- c(1:2:length(c))=a;
-
- Ron Dilsavor
- dilsavor@ee.eng.ohio-state.edu
-