File: sensi.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (60 lines) | stat: -rw-r--r-- 1,353 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function [Se,R,T]=sensi(G,Sk,flag)
// [Se,R,T]=sensi(G,Sk) computes sensitivity functions
// If flag='o' or no flag:
// [Se;R;T]= [inv(eye+G*K);K*inv(eye+G*K);G*K*inv(eye+G*K)];
// 
// flag='i'
// [Si,Ri,Ti]= [inv(eye+K*G);G*inv(eye+K*G);K*G*inv(eye+K*G)];
//!
// Copyright INRIA
[LHS,RHS]=argn(0);
if RHS==2 then flag='o';end
select flag
  case 'o'
G1=G(1);Sk1=Sk(1);
ssflag=0;
if G1(1)=='r' then G=tf2ss(G);ssflag=1;end
if Sk1(1)=='r' then Sk=tf2ss(Sk);ssflag=ssflag+1;end
[ny,nu]=size(G);Iu=eye(nu,nu);Iy=eye(ny,ny);
Ouy=zeros(nu,ny);Oyu=zeros(ny,nu);Ouu=zeros(nu,nu);
Oyy=zeros(ny,ny);
W1=[Iy,Oyu,Oyy;
    Ouy,Iu,Ouy;
   -Iy,Oyu,Iy;
    Iy,Oyu,Oyy];
W2=[Iy,-G;
    Ouy,Iu;
    Iy,Oyu];
SRT=lft(W1*W2,Sk);
Se=SRT(1:ny,:);
R=SRT((ny+1):(ny+nu),:);
T=SRT((nu+ny+1):(nu+ny+ny),:);
if ssflag >0 then
   Se=ss2tf(Se);R=ss2tf(R);T=ss2tf(T);
end
  case 'i'
G1=G(1);Sk1=Sk(1);
ssflag=0;
if G1(1)=='r' then G=tf2ss(G);ssflag=1;end
if Sk1(1)=='r' then Sk=tf2ss(Sk);ssflag=ssflag+1;end
[ny,nu]=size(G);Iu=eye(nu,nu);Iy=eye(ny,ny);
Ouy=zeros(nu,ny);Oyu=zeros(ny,nu);Ouu=zeros(nu,nu);
Oyy=zeros(ny,ny);
 W1=[Iu,-Iu;
     Oyu,Oyu;
     Ouu,Iu;
     Oyu,Oyu];
 W2=[Ouy;Iy;Ouy;Iy];
 W3=[Iu,-Iu];
 P=W1+W2*G*W3;
SRT=lft(P,Sk);
Se=SRT(1:nu,:);
R=SRT((nu+1):(ny+nu),:);
T=SRT((nu+ny+1):(nu+ny+nu),:);
if ssflag >0 then
   Se=ss2tf(Se);R=ss2tf(R);T=ss2tf(T);
end
end