Code covered by the BSD License  

Highlights from
Circular Matrix computation

2.66667

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

Circular Matrix computation

by Massimo Fierro

 

29 Jan 2009 (Updated 02 Feb 2009)

Commodity function for building a circulant matrix given a vector

| Watch this File

File Information
Description

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

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

     ans =

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

Acknowledgements
This submission has inspired the following:
Circulant matrix
MATLAB release MATLAB 7.7 (R2008b)
Other requirements Any version of Matlab with the circshift function
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
31 Jan 2009 Jos (10584)

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 Massimo Fierro

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.

01 Feb 2009 Duane Hanselman

Authors should not pad the star rating of their submissions.

02 Feb 2009 Jos (10584)

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

02 Feb 2009 Massimo Fierro

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.

02 Feb 2009 Husam Aldahiyat

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

02 Feb 2009 Jos (10584)

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.

Please login to add a comment or rating.
Updates
01 Feb 2009

UPDATE Feb 02, 2009: added help

02 Feb 2009

Slightly modified the help and matched the file description with it

Tag Activity for this File
Tag Applied By Date/Time
matrix Massimo Fierro 29 Jan 2009 16:49:54
circulant Massimo Fierro 29 Jan 2009 16:49:54

Contact us at files@mathworks.com