Line | |
---|
1 | function Y=clean(Y) |
---|
2 | %clean (overloaded) |
---|
3 | |
---|
4 | % Author Johan Löfberg |
---|
5 | % $Id: clean.m,v 1.1 2006/07/13 19:40:59 joloef Exp $ |
---|
6 | |
---|
7 | i = length(Y.dim); |
---|
8 | while i>2 |
---|
9 | if Y.dim(end) == 1 |
---|
10 | Y.dim(end) = []; |
---|
11 | i = i - 1; |
---|
12 | else |
---|
13 | break |
---|
14 | end |
---|
15 | end |
---|
16 | if length(Y.dim) == 2; |
---|
17 | Y = reshape(sdpvar(Y),Y.dim(1),Y.dim(2)); |
---|
18 | Y = clean(Y); |
---|
19 | else |
---|
20 | temp = any(Y.basis,1); |
---|
21 | temp = temp(2:end); |
---|
22 | index = find(temp); |
---|
23 | if ~isempty(index) |
---|
24 | Z = Y; |
---|
25 | if length(index)~=length(Y.lmi_variables) |
---|
26 | Y.basis = Y.basis(:,[1 1+index]); |
---|
27 | Y.lmi_variables = Y.lmi_variables(index); |
---|
28 | end |
---|
29 | if ~isreal(Y.basis) & nargin==2 |
---|
30 | basis_real = real(Y.basis); |
---|
31 | basis_imag = imag(Y.basis); |
---|
32 | basis_real(abs(basis_real)<tol) = 0; |
---|
33 | basis_imag(abs(basis_imag)<tol) = 0; |
---|
34 | Y.basis = basis_real + sqrt(-1)*basis_imag; |
---|
35 | end |
---|
36 | else |
---|
37 | Y = full(reshape(Y.basis(:,1),Y.dim)); |
---|
38 | end |
---|
39 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.