Line | |
---|
1 | function [p,c,v] = polynomial(x,dmax,dmin) |
---|
2 | %POLYNOMIAL Creates parameterized polynomial |
---|
3 | % |
---|
4 | % [p,c,v] = polynomial(x,dmax,dmin) |
---|
5 | % |
---|
6 | % POLYNOMIAL is a quick way to define a parameterized polynomial p=c'*v, |
---|
7 | % with all monomials of dmin <= degree(p,x) <= dmax. The coefficients in |
---|
8 | % the polynomial are c while v is the monomial basis. |
---|
9 | % |
---|
10 | % Example: |
---|
11 | % |
---|
12 | % Paramterized quartic |
---|
13 | % x = sdpvar(2,1); |
---|
14 | % p = polynomial(x,4); |
---|
15 | % |
---|
16 | % See also MONOLIST, COEFFICIENTS |
---|
17 | |
---|
18 | % Author Johan Löfberg |
---|
19 | % $Id: polynomial.m,v 1.3 2006/08/16 15:57:36 joloef Exp $ |
---|
20 | |
---|
21 | if nargin<3 |
---|
22 | dmin = 0; |
---|
23 | end |
---|
24 | |
---|
25 | v = monolist(x,dmax); |
---|
26 | if dmin <= dmax & dmin>0 |
---|
27 | s = nchoosek(length(x) + dmin-1,dmin-1); |
---|
28 | v = extsubsref(v,s+1:length(v)); |
---|
29 | end |
---|
30 | c = sdpvar(length(v),1); |
---|
31 | p = c'*v; |
---|
Note: See
TracBrowser
for help on using the repository browser.