# Talk:Beginning with CVX

(Difference between revisions)
 Revision as of 02:34, 5 February 2009 (edit)← Previous diff Revision as of 10:16, 5 February 2009 (edit) (undo)Next diff → Line 3: Line 3: -------------------------------------------------------------------- -------------------------------------------------------------------- - Some one tell to me to upload the article that I'm reading for all the people could read it. I didn't know how to upload it, so I scan it and upload like some images (jpg). If it's wrong just tell to me and I will move or re-upload like jpg. The images are pag1 to pag7. The paper its: Pole assignment of linear uncertain systems in a sector via a lyapunov - tipe approach. D. Arzeiler, J. Bernussou and G. Garcia. IEEE transactions automatic control, vol 38, nº 7, July 1993. The paper its: Pole assignment of linear uncertain systems in a sector via a lyapunov - tipe approach. D. Arzeiler, J. Bernussou and G. Garcia. IEEE transactions automatic control, vol 38, nº 7, July 1993. Line 9: Line 8: Thanks a lot for all the ideas, they all are greats. Thanks a lot for all the ideas, they all are greats. - I'm at work so I can't programm now, I will do it later. + I don't know how to initialice Epsilon1 and Epsilon2 I'm going to research in the references of my article (Cross fingers) - + - At the paper puts: + - + - normalized eigenvectors: v_W. And + - + -
+
-                                                            v_W ' * W * v_W >= Epsilon1                                                                                                                                                                                                                                                     +
-
+ - + - v_W its a matrix, and Epsilon1 I think its an escalar, so a good idea could be: + - + -
[ v_W ] = eig ( full ( W ) )                                                                                                                                                                                                                                               +
-                                                            ....                                                                                                                                                                                                                                                                            +
-                                                            v_W_1 = v_W( : , 1 ) / norm ( v_W ( : , 1 ) ) ;                                                                                                                                                                                                                                 +
-                                                            v_W_2 = v_W( : , 2 ) / norm ( v_W ( : , 2 ) ) ;                                                                                                                                                                                                                                 +
-                                                            v_W_3 = v_W( : , 3 ) / norm ( v_W ( : , 3 ) ) ;                                                                                                                                                                                                                                 +
-                                                            v_W_4 = v_W( : , 4 ) / norm ( v_W ( : , 4 ) ) ;                                                                                                                                                                                                                                 +
-                                                            ....                                                                                                                                                                                                                                                                            +
-                                                            v_W_1 ' * W * v_W_1 >= Epsilon1                                                                                                                                                                                                                                                 +
-                                                            v_W_2 ' * W * v_W_2 >= Epsilon1                                                                                                                                                                                                                                                 +
-                                                            v_W_3 ' * W * v_W_3 >= Epsilon1                                                                                                                                                                                                                                                 +
-                                                            v_W_4 ' * W * v_W_4 >= Epsilon1                                                                                                                                                                                                                                                 +
-                                                            ....                                                                                                                                                                                                                                                                            +
-
+ - + - or + -
[ v_W ] = eig ( full ( W ) )                                                                                                                                                                                                                                               +
-                                                            ....                                                                                                                                                                                                                                                                            +
-                                                            v_W( : , 1 ) = v_W( : , 1 ) / norm ( v_W ( : , 1 ) ) ;                                                                                                                                                                                                                          +
-                                                            v_W( : , 2 ) = v_W( : , 2 ) / norm ( v_W ( : , 2 ) ) ;                                                                                                                                                                                                                          +
-                                                            v_W( : , 3 ) = v_W( : , 3 ) / norm ( v_W ( : , 3 ) ) ;                                                                                                                                                                                                                          +
-                                                            v_W( : , 4 ) = v_W( : , 4 ) / norm ( v_W ( : , 4 ) ) ;                                                                                                                                                                                                                          +
-                                                            ....                                                                                                                                                                                                                                                                            +
-                                                            v_W ' * W * v_W >= Epsilon1 * eye ( 4 );                                                                                                                                                                                                                                        +
-                                                            ....                                                                                                                                                                                                                                                                            +
-
+ - + - I haven't Matlab here so it could be horrible. + - + - -------------------------------------------------------------------- + - + - + - Thanks for the ideas it's great. Thank you very much :D. + - + - I have an answer, how to calculate the normalized eigenvector. + - + - Maybe?
[v_W]=eig(full(W))/norm ....
+ - + - I've changed Epsilon1, Epsilon2, they aren't a variable, I think they are constants. + - + - I'm going to see how to initialice (I'm going to research in the references of my article (Cross fingers) + Thanks a lot again. Thanks a lot again. Line 67: Line 15:

-                                                                                                                                                                                                                                                                                                                                            +                                                               %0)Initialization
clear all;                                                                                                                                                                                                                                                                                                                                      clear all;
n=2; m=1;                                                                                                                                                                                                                                                                                                                                       n=2; m=1;
Line 73:                                                                                                                                                                                                                                                                                                                                     Line 21:
A_a=3*eye(2*n,2*n)                                                                                                                                                                                                                                                                                                                              A_a=3*eye(2*n,2*n)
B_a=4*eye(2*n,2*m)                                                                                                                                                                                                                                                                                                                              B_a=4*eye(2*n,2*m)
+
+                                                               %1)1
W=eye(4)                                                                                                                                                                                                                                                                                                                                        W=eye(4)
R=(zeros(2,4))                                                                                                                                                                                                                                                                                                                                  R=(zeros(2,4))

+                                                               %2)2
H=W*A_a'+A_a*W-B_a*R-R'*B_a'                                                                                                                                                                                                                                                                                                                    H=W*A_a'+A_a*W-B_a*R-R'*B_a'

Line 81:                                                                                                                                                                                                                                                                                                                                     Line 32:
lamda_H=max(eig(H))                                                                                                                                                                                                                                                                                                                             lamda_H=max(eig(H))

-                                                            Epsilon1=1;                                                                                                                                                                                                                                                                     +                                                               Epsilon1=11;
-                                                            Epsilon2=1;                                                                                                                                                                                                                                                                     +                                                               Epsilon2=0.1;

if(lamda_W>=Epsilon1)                                                                                                                                                                                                                                                                                                                           if(lamda_W>=Epsilon1)
Line 91:                                                                                                                                                                                                                                                                                                                                     Line 42:
end                                                                                                                                                                                                                                                                                                                                             end

-                                                                                                                                                                                                                                                                                                                                            +                                                               %3)3
-                                                            %v_W=eig(W)/(abs(eig(W)))                                                                                                                                                                                                                                                       +                                                               [v_W,D] = eig( full ( W ) )
-                                                            %v_W=eig(full(W))/abs(full(W))%%normalized eigenvector :|                                                                                                                                                                                                                       +                                                               [v_H,D] = eig( full ( H ) )
-                                                            %v_H=eig(H)/max(eig(H))                                                                                                                                                                                                                                                         +
-                                                                                                                                                                                                                                                                                                                                            +
-                                                                                                                                                                                                                                                                                                                                            +
-                                                            while para==0                                                                                                                                                                                                                                                                   +

-                                                            [v_W,D] = eig(W)                                                                                                                                                                                                                                                                +                                                               v_W_1 = v_W( : , 1 ) / norm ( v_W ( : , 1 ) ) ;
-                                                            [v_H,D] = eig(H)                                                                                                                                                                                                                                                                +                                                               v_W_2 = v_W( : , 2 ) / norm ( v_W ( : , 2 ) ) ;
+                                                               v_W_3 = v_W( : , 3 ) / norm ( v_W ( : , 3 ) ) ;
+                                                               v_W_4 = v_W( : , 4 ) / norm ( v_W ( : , 4 ) ) ;

+                                                               v_H_1 = v_H( : , 1 ) / norm ( v_H ( : , 1 ) ) ;
+                                                               v_H_2 = v_H( : , 2 ) / norm ( v_H ( : , 2 ) ) ;
+                                                               v_H_3 = v_H( : , 3 ) / norm ( v_H ( : , 3 ) ) ;
+                                                               v_H_4 = v_H( : , 4 ) / norm ( v_H ( : , 4 ) ) ;
+
+                                                               %4a)4a
if ( Epsilon1 - lamda_W )>(lamda_H+Epsilon2)                                                                                                                                                                                                                                                                                                    if ( Epsilon1 - lamda_W )>(lamda_H+Epsilon2)
+                                                               Caso=1 %For know where am I

cvx_begin                                                                                                                                                                                                                                                                                                                                       cvx_begin
-
variables p1 p2 W(4,4) R(2,4)                                                                                                                                                                                                                                                                                                                   variables p1 p2 W(4,4) R(2,4)

Line 111:                                                                                                                                                                                                                                                                                                                                    Line 66:

subject to                                                                                                                                                                                                                                                                                                                                      subject to
-
-                                                            W(1,1)<=p1
-                                                            W(2,2)<=p1
-                                                            W(1,1)>=Epsilon1
-                                                            W(2,2)>=Epsilon1
-                                                            W(3,3)==W(1,1)
-                                                            W(4,4)==W(2,2)
-
-                                                            R(1,1)>=-p2
-                                                            R(1,1)<=p2
-                                                            R(2,3)==R(1,1)

-                                                            R(1,2)>=-p2                                                                                                                                                                                                                                                                     +                                                               W(1,1)<=p1
-                                                            R(1,2)<=p2                                                                                                                                                                                                                                                                      +                                                               W(2,2)<=p1
-                                                            R(2,4)==R(1,2)                                                                                                                                                                                                                                                                  +                                                               W(1,1)>=Epsilon1
+                                                               W(2,2)>=Epsilon1
+                                                               W(3,3)==W(1,1)
+                                                               W(4,4)==W(2,2)
+
+                                                               R(1,1)>=-p2
+                                                               R(1,1)<=p2
+                                                               R(2,3)==R(1,1)
+                                                               R(1,2)>=-p2
+                                                               R(1,2)<=p2
+                                                               R(2,4)==R(1,2)

H=W*A_a'+A_a*W-B_a*R-R'*B_a'                                                                                                                                                                                                                                                                                                                    H=W*A_a'+A_a*W-B_a*R-R'*B_a'

-                                                            W - Epsilon1*eye(2*n) == semidefinite(2*n);                                                                                                                                                                                                                                     +                                                               v_W'*W*v_W - Epsilon1*eye(2*n) == semidefinite(2*n);
-                                                            Epsilon2*eye(2*n) + H == -semidefinite(2*n);                                                                                                                                                                                                                                    +
-                                                                                                                                                                                                                                                                                                                                            +
-                                                            v_W'*W*v_W>=Epsilon1*eye(4)                                                                                                                                                                                                                                                     +

cvx_end                                                                                                                                                                                                                                                                                                                                         cvx_end

-                                                            else                                                                                                                                                                                                                                                                            +                                                               else %4b)4b

+                                                               Caso = 2
cvx_begin                                                                                                                                                                                                                                                                                                                                       cvx_begin

Line 146:                                                                                                                                                                                                                                                                                                                                    Line 98:
subject to                                                                                                                                                                                                                                                                                                                                      subject to

-                                                            W(1,1)>=Epsilon1                                                                                                                                                                                                                                                                +                                                               W(1,1)>=Epsilon1
-                                                            W(2,2)>=Epsilon1                                                                                                                                                                                                                                                                +                                                               W(2,2)>=Epsilon1
+                                                               W(1,1)<=p1
+                                                               W(2,2)<=p1
+                                                               W(3,3)==W(1,1)
+                                                               W(4,4)==W(2,2)

-                                                            W(1,1)<=p1                                                                                                                                                                                                                                                                      +                                                               R(1,1)>=-p2
-                                                            W(2,2)<=p1                                                                                                                                                                                                                                                                      +                                                               R(1,1)<=p2
-                                                            W(3,3)==W(1,1)                                                                                                                                                                                                                                                                  +                                                               R(2,3)==R(1,1)
-                                                            W(4,4)==W(2,2)                                                                                                                                                                                                                                                                  +                                                               R(1,2)>=-p2
+                                                               R(1,2)<=p2
+                                                               R(2,4)==R(1,2)

-
-                                                            R(1,1)>=-p2
-                                                            R(1,1)<=p2
-                                                            R(2,3)==R(1,1)
-
-                                                            R(1,2)>=-p2
-                                                            R(1,2)<=p2
-                                                            R(2,4)==R(1,2)
-
H=W*A_a'+A_a*W-B_a*R-R'*B_a'                                                                                                                                                                                                                                                                                                                    H=W*A_a'+A_a*W-B_a*R-R'*B_a'

-                                                            W - Epsilon1*eye(2*n) == semidefinite(2*n);                                                                                                                                                                                                                                     +                                                               Epsilon2*eye(2*n) + v_H'*H*v_H == -semidefinite(2*n);
-                                                            Epsilon2*eye(2*n) + H == -semidefinite(2*n);                                                                                                                                                                                                                                    +
-                                                                                                                                                                                                                                                                                                                                            +
-                                                            v_H'*H*v_H<=-Epsilon2*eye(4)                                                                                                                                                                                                                                                    +

cvx_end                                                                                                                                                                                                                                                                                                                                         cvx_end
end                                                                                                                                                                                                                                                                                                                                             end

-                                                            lamda_W=min(eig(full(W)))                                                                                                                                                                                                                                                       +                                                               lamda_W = min ( eig ( full ( W ) ) )
-                                                            lamda_H=max(eig(H))                                                                                                                                                                                                                                                             +                                                               lamda_H = max ( eig ( full ( H ) ) )

-                                                            % v_W=eig(full(W))/max(eig(full(W)))%%Cálculo del normalized eigenvector                                                                                                                                                                                                        +                                                               R
-                                                            % v_H=eig(H)/max(eig(H))                                                                                                                                                                                                                                                        +                                                               W=full(W)
+                                                               K=R/W

-                                                            %STOP                                                                                                                                                                                                                                                                           +
- if(lamda_W>=Epsilon1) + - if(lamda_H<=-Epsilon2) para=1 + - else para = 0 + - end + - else para =0 + - end + - + - end + - + - R + - W + - K=R/W
+

## Revision as of 10:16, 5 February 2009

```lamda_W=eig(full(W))
```

The paper its: Pole assignment of linear uncertain systems in a sector via a lyapunov - tipe approach. D. Arzeiler, J. Bernussou and G. Garcia. IEEE transactions automatic control, vol 38, nº 7, July 1993.

Thanks a lot for all the ideas, they all are greats.

I don't know how to initialice Epsilon1 and Epsilon2 I'm going to research in the references of my article (Cross fingers)

Thanks a lot again.

Here is the new code:

```%0)Initialization
clear all;
n=2; m=1;

A_a=3*eye(2*n,2*n)
B_a=4*eye(2*n,2*m)

%1)1
W=eye(4)
R=(zeros(2,4))

%2)2
H=W*A_a'+A_a*W-B_a*R-R'*B_a'

lamda_W=min(eig(full(W)))
lamda_H=max(eig(H))

Epsilon1=11;
Epsilon2=0.1;

if(lamda_W>=Epsilon1)
if(lamda_H<=-Epsilon2)     para=1
else para = 0
end
else para =0
end

%3)3
[v_W,D] = eig( full ( W ) )
[v_H,D] = eig( full ( H ) )

v_W_1 = v_W( : , 1 ) / norm ( v_W ( : , 1 ) ) ;
v_W_2 = v_W( : , 2 ) / norm ( v_W ( : , 2 ) ) ;
v_W_3 = v_W( : , 3 ) / norm ( v_W ( : , 3 ) ) ;
v_W_4 = v_W( : , 4 ) / norm ( v_W ( : , 4 ) ) ;

v_H_1 = v_H( : , 1 ) / norm ( v_H ( : , 1 ) ) ;
v_H_2 = v_H( : , 2 ) / norm ( v_H ( : , 2 ) ) ;
v_H_3 = v_H( : , 3 ) / norm ( v_H ( : , 3 ) ) ;
v_H_4 = v_H( : , 4 ) / norm ( v_H ( : , 4 ) ) ;

%4a)4a
if ( Epsilon1 - lamda_W )>(lamda_H+Epsilon2)
Caso=1 %For know where am I

cvx_begin
variables p1 p2 W(4,4) R(2,4)

minimize (p1+p2)

subject to

W(1,1)<=p1
W(2,2)<=p1
W(1,1)>=Epsilon1
W(2,2)>=Epsilon1
W(3,3)==W(1,1)
W(4,4)==W(2,2)

R(1,1)>=-p2
R(1,1)<=p2
R(2,3)==R(1,1)
R(1,2)>=-p2
R(1,2)<=p2
R(2,4)==R(1,2)

H=W*A_a'+A_a*W-B_a*R-R'*B_a'

v_W'*W*v_W - Epsilon1*eye(2*n) == semidefinite(2*n);

cvx_end

else %4b)4b

Caso = 2
cvx_begin

variables p1 p2 W(4,4) R(2,4)

minimize (p1+p2)

subject to

W(1,1)>=Epsilon1
W(2,2)>=Epsilon1
W(1,1)<=p1
W(2,2)<=p1
W(3,3)==W(1,1)
W(4,4)==W(2,2)

R(1,1)>=-p2
R(1,1)<=p2
R(2,3)==R(1,1)
R(1,2)>=-p2
R(1,2)<=p2
R(2,4)==R(1,2)

H=W*A_a'+A_a*W-B_a*R-R'*B_a'

Epsilon2*eye(2*n) + v_H'*H*v_H == -semidefinite(2*n);

cvx_end
end

lamda_W = min ( eig ( full ( W ) ) )
lamda_H = max ( eig ( full ( H ) ) )

R
W=full(W)
K=R/W

```