Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Reading from beginning and end of an array and repeat
Date: Sun, 22 Feb 2009 16:44:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 40
Message-ID: <gnrvci$6e5$1@fred.mathworks.com>
References: <33098052.1235314424604.JavaMail.jakarta@nitrogen.mathforum.org> <gnruiq$cr2$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 1235321042 6597 172.30.248.38 (22 Feb 2009 16:44:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 22 Feb 2009 16:44:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1702011
Xref: news.mathworks.com comp.soft-sys.matlab:520009

"Jos " <#10584@fileexchange.com> wrote in message <gnruiq$cr2$1@fred.mathworks.com>...
> enviro <farhadnejadkoorki@yahoo.co.uk> wrote in message <33098052.1235314424604.JavaMail.jakarta@nitrogen.mathforum.org>...
> > Hello everyone
> > I want to select an array(s)with length n out of
> > a bigger array (z) in a way that the 
> > s =[162 320 169 280 172]' 
> > or(get one from first row and one from end and repeat until it reaches n)
> > How to  write a code to get array s? 
> > below is what I tried.
> > 
> > z=[162   169   172   184   199   205 220 240 280 320]'
> > n=5;
> > [p,q]=size(z);
> > s=zeros(n,1);
> > [d,e]=size(s);
> > 
> > 
> > for i=1:p;
> >     for j=p:p-(i-1);
> >         for d=1:n;
> >             for f=d+1:n;
> >                 s(d)=z(i); 
> >                 s(f)=z(j);
> >             end
> >         end
> >     end
> > end
> > s
> 
> ???
> 
> I do not understand what you want. Can you please rephrase your problem? And given an example of the input and expected output?
> 
> Jos
-------------------------------------------------------------
input=[162   169   172   184   199   205 220 240 280 320]'
output=[162 320 169 280 172]'
I want to select 5 number from input as above. selection must happens (input(1),
input(10),input(2),input(9),input(3)...).
Please let me know if it is not clear. thanks in advance