Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Construct a matrix with rotational column elements
Date: Tue, 29 Nov 2011 19:05:12 +0000 (UTC)
Organization: Xoran Technologies
Lines: 31
Message-ID: <jb3ad8$lqf$1@newscl01ah.mathworks.com>
References: <jb395o$haj$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1322593512 22351 172.30.248.37 (29 Nov 2011 19:05:12 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 29 Nov 2011 19:05:12 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:750842

"Wendy " <wlq121@gmail.com> wrote in message <jb395o$haj$1@newscl01ah.mathworks.com>...
> Hi all,
> 
> I want to construct a matrix with rotational column elements in each row. Following is an example
> 
>  A =
>      1     2     3     4
>      4     1     2     3
>      3     4     1     2
>      2     3     4     1
> 
> Given r = [1 2 3 4], instead of constructing the matrix row by row, is there any function in Matlab for doing this automatically?
==================


If the matrix is to be sparse, it would be recommendable to use this tool with the 'circ' option.


http://www.mathworks.com/matlabcentral/fileexchange/26292-regular-control-point-interpolation-matrix-with-boundary-conditions


It can also handle small examples like what you've described:

>> full(interpMatrix([1 2 3 4],1,4,1,'circ')).'

ans =

     1     2     3     4
     4     1     2     3
     3     4     1     2
     2     3     4     1