Home > source > generateSymsL.m

generateSymsL

PURPOSE ^

Generate the syms matrix L.

SYNOPSIS ^

function [ L ] = generateSymsL( n, m, hState, d )

DESCRIPTION ^

Generate the syms matrix L.

Generate syms matrix L, where n is the degree of matrix A and m is the
degree of A and m is the degree of the state vector x in homogeneous form.

Prototype: [L] = generateSymsL(n, m, hState, d)

Input:     n - Degree of A
           m - Degree of the state vector x in homogeneous form
           hState - Homogeneous state vector
           d - Dimension of homogeneous state vector hState

Output:    L - Syms matrix L

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %Generate the syms matrix L.
0002 %
0003 %Generate syms matrix L, where n is the degree of matrix A and m is the
0004 %degree of A and m is the degree of the state vector x in homogeneous form.
0005 %
0006 %Prototype: [L] = generateSymsL(n, m, hState, d)
0007 %
0008 %Input:     n - Degree of A
0009 %           m - Degree of the state vector x in homogeneous form
0010 %           hState - Homogeneous state vector
0011 %           d - Dimension of homogeneous state vector hState
0012 %
0013 %Output:    L - Syms matrix L
0014 
0015 function [ L ] = generateSymsL( n, m, hState, d )
0016 
0017 syms x;
0018 for i=1:n
0019     x(i) = ['x_' int2str(i)];
0020 end
0021 
0022 %Row Vector hState without using ' because of conj() function
0023 for i=1:d
0024     hStateRow(i) = hState(i);
0025 end
0026 
0027 %Build the paramtric and symmetric matrix L.
0028 %If degree of matrix L is dxd, the number of parameters is defined as:
0029 %numOfParam = d + (d-1) + (d-2) + ... + 1
0030 numOfParam = 0;
0031 for i=1:d
0032     numOfParam = numOfParam + i;
0033 end
0034 
0035 syms alfa;
0036 
0037 for i=1:numOfParam
0038     alfa(i) = sdpvar(1);
0039 end
0040 
0041 alfa_index = 1;
0042 for i=1:d
0043     for j=1:d
0044         if j>=i
0045             L(i,j)=alfa(alfa_index);
0046             alfa_index = alfa_index + 1;
0047         else
0048             L(i,j)=L(j,i);
0049         end
0050     end
0051 end
0052 
0053 system=hStateRow*L*hState;
0054 
0055 k=1;
0056 for i=1:d
0057     for j=i:d
0058         divisors(k) = hState(i)*hState(j);
0059         k=k+1;
0060     end
0061 end
0062 
0063 for i=1:length(divisors)
0064     chr = char(expand(system/divisors(i)));
0065     equation{i} = generateCoefficientEquationFromString(chr);
0066 end
0067 
0068 equation = clearEquation(equation);
0069 
0070 warning off
0071 for i=1:length(equation)
0072     actualEquation = equation{i};
0073     found = false;
0074     j=1;
0075     while found == false && j <= length(alfa)
0076         actualVariable = alfa(j);
0077         if actualVariable == 0
0078             actualVariable = NaN;
0079         end
0080         if strfind(equation{i},char(actualVariable))
0081             alfa(j) = solve(actualEquation,actualVariable);
0082             found = true;
0083         else
0084             j = j+1;
0085         end
0086     end
0087 end
0088 warning on
0089 
0090 alfa_index = 1;
0091 for i=1:d
0092     for j=1:d
0093         if j>=i
0094             L(i,j)=strrep(char(alfa(alfa_index)), ' ', '');
0095             alfa_index = alfa_index + 1;
0096         else
0097             L(i,j)=L(j,i);
0098         end
0099     end
0100 end
0101 
0102 return;
0103 
0104 end

Generated on Thu 24-Sep-2009 17:17:32 by m2html © 2005