View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Circular Matrix computation

2.7 | 4 ratings Rate this file 3 Downloads (last 30 days) File Size: 1.36 KB File ID: #22814 Version: 1.2

Circular Matrix computation


Massimo Fierro (view profile)


29 Jan 2009 (Updated )

Commodity function for building a circulant matrix given a vector

| Watch this File

File Information

circulant Computes the circulant matrix of a vector.

  circulant(vec) is a max(size(vec))-by-max(size(vec)) circulant
  matrix built with the elements of vec

  Note: The parameter may be either a column or row vector

     v = [ 1 2 3 4 ];
     circulant( v )

     ans =

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


Hysteresis Thresholding inspired this file.

This file inspired Circulant Matrix.

MATLAB release MATLAB 7.7 (R2008b)
Other requirements Any version of Matlab with the circshift function
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
02 Feb 2009 Jos (10584)

Jos (10584) (view profile)

The author should be commended for adding a good help section. Although faster and better algorithms exist, I concur with Husam A. that this is indeed a nice effort, and therefor happily raise my rating.

02 Feb 2009 Husam Aldahiyat

Don't listen to these elitists.
Good work and nice effort.

02 Feb 2009 Massimo Fierro

Massimo Fierro (view profile)

Thanks Jos for the comment, I didn't know about the hankel function.
Had I known, I would have definitely done it that way (as indexing always works better in Matlab).

I am quite surprised, though, that there is no function in the standard library for producing such a common matrix.

Comment only
02 Feb 2009 Jos (10584)

Jos (10584) (view profile)

Some indexing will give you the same result
V = IN(:) ;
idx = hankel(1:numel(V),0:numel(V)-1)
% idx = hankel(1:numel(V)) + hankel(zeros(1,numl(V)),0:numel(V)-1)
OUT = V(ix) ;

Comment only
01 Feb 2009 Duane Hanselman

Authors should not pad the star rating of their submissions.

01 Feb 2009 Massimo Fierro

Massimo Fierro (view profile)

I will gladly do, but I thought that the description "The function accepts both column and row vectors and produces the circulant matrix associated." would suffice.

Comment only
31 Jan 2009 Jos (10584)

Jos (10584) (view profile)

Please add a proper help section including a H1 line, syntax and example. At present this submission is completely useless for anyone but the author.

01 Feb 2009 1.1

UPDATE Feb 02, 2009: added help

02 Feb 2009 1.2

Slightly modified the help and matched the file description with it

Contact us