Home > analyzePRF > utilities > constructpolynomialmatrix.m

constructpolynomialmatrix

PURPOSE ^

function f = constructpolynomialmatrix(n,degrees)

SYNOPSIS ^

function f = constructpolynomialmatrix(n,degrees)

DESCRIPTION ^

 function f = constructpolynomialmatrix(n,degrees)

 <n> is the number of points
 <degrees> is a vector of polynomial degrees

 return a matrix of dimensions <n> x length(<degrees>)
 with polynomials in the columns (e.g. x, x^2, x^3, etc.).
 these are evaluated over the range [-1,1].
 beware of numerical precision issues for high degrees...

 example:
 figure; imagesc(constructpolynomialmatrix(100,0:3));

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function f = constructpolynomialmatrix(n,degrees)
0002 
0003 % function f = constructpolynomialmatrix(n,degrees)
0004 %
0005 % <n> is the number of points
0006 % <degrees> is a vector of polynomial degrees
0007 %
0008 % return a matrix of dimensions <n> x length(<degrees>)
0009 % with polynomials in the columns (e.g. x, x^2, x^3, etc.).
0010 % these are evaluated over the range [-1,1].
0011 % beware of numerical precision issues for high degrees...
0012 %
0013 % example:
0014 % figure; imagesc(constructpolynomialmatrix(100,0:3));
0015 
0016 % do it
0017 f = [];
0018 temp = linspace(-1,1,n)';
0019 for p=1:length(degrees)
0020   f = cat(2,f,temp .^ degrees(p));
0021 end

Generated on Wed 18-Jun-2014 21:47:41 by m2html © 2005