File Exchange

image thumbnail

Circular Matrix computation

version 1.2 (1.36 KB) by

Commodity function for building a circulant matrix given a vector

4 Ratings



View License

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

Comments and Ratings (7)

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.

Husam Aldahiyat

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

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.

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) ;

Authors should not pad the star rating of their submissions.

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.

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.



Slightly modified the help and matched the file description with it


UPDATE Feb 02, 2009: added help

MATLAB Release
MATLAB 7.7 (R2008b)
Tags Add Tags

Inspired by: Hysteresis Thresholding

Inspired: Circulant matrix

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

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

» Watch video