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