home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / softsys / matlab / 202 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.5 KB  |  45 lines

  1. Newsgroups: comp.soft-sys.matlab
  2. 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
  3. From: dilsavor@dosequis.eng.ohio-state.edu (Ron L. Dilsavor)
  4. Subject: Re: Combining vectors
  5. Message-ID: <1993Jan27.155815.23225@ee.eng.ohio-state.edu>
  6. Sender: news@ee.eng.ohio-state.edu
  7. Organization: The Ohio State University Dept of Electrical Engineering
  8. References: <1993Jan26.182616.11550@vax.oxford.ac.uk> <1k5hf2INNlgs@shelley.u.washington.edu>
  9. Date: Wed, 27 Jan 1993 15:58:15 GMT
  10. Lines: 33
  11.  
  12. In article <1k5hf2INNlgs@shelley.u.washington.edu> phantom@stein2.u.washington.edu (The Phantom) writes:
  13. >In article <1993Jan26.182616.11550@vax.oxford.ac.uk> reese@vax.oxford.ac.uk writes:
  14. >>
  15. >>
  16. >>I want to take two vectors and combine them, e.g.
  17. >>[ a b c d e]  and [ f g h i j ] 
  18. >>become  [ a f b g c h d i e j ]
  19. >>
  20. >
  21. >say a=[ a b c d e ] and b=[ f g h i j ] -- an easy way to do this would be
  22. >using ...
  23. >
  24. >len=length(a);            %assuming length(a), length(b) are equal
  25. >FOR count=1:len,
  26. >    c((count*2)-1)=a(count);
  27. >    c((count*2)=b(count);
  28. >END
  29. >
  30. >that seems to work, anyway. just work with the commands for picking out 
  31. >certain matrix spots and FOR loops, and you should be able to comprise 
  32. >something that works both ways.
  33. >
  34. >mt
  35. >
  36.  
  37. Try to avoid using slow FOR loops if you can.
  38. Here is a neat way which is faster
  39.  
  40. c(2:2:2*length(b))=b;
  41. c(1:2:length(c))=a;
  42.  
  43. Ron Dilsavor
  44. dilsavor@ee.eng.ohio-state.edu
  45.