Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: shifting row  in large matrix
Date: Wed, 25 Feb 2009 08:33:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 29
Message-ID: <go2vnt$ho8$1@fred.mathworks.com>
References: <18203389.1235548336327.JavaMail.jakarta@nitrogen.mathforum.org> <go2vgd$sg0$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1235550781 18184 172.30.248.37 (25 Feb 2009 08:33:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 25 Feb 2009 08:33:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:520639

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <go2vgd$sg0$1@fred.mathworks.com>...
> mahmud <mahmusyubli@gmail.com> wrote in message <18203389.1235548336327.JavaMail.jakarta@nitrogen.mathforum.org>...
> > does anyone know how to shift element in a row?
> > 
> > example:
> > 
> > 1 2 3 4 5
> > 1 1 1 0 0
> > 5 4 3 2 1
> > 
> > becomes
> > 
> > 1 2 3 4 5
> > 0 1 1 1 0
> > 5 4 3 2 1
> > 
> > anyone? or you can show me if there is a function in matlab that can do that.
> > tq
> 
>   To shift a row r to the right by p positions do this
> 
>  n = length(r);
>  r(mod(1:n+p-1,n)+1) = r;
> 
> Roger Stafford

  Actually it is easier to use 'circshift'.

Roger Stafford