File: cont_frm.sci

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (40 lines) | stat: -rw-r--r-- 848 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
function sl=cont_frm(num,den)
//Controllable state-space form of the transfer num/den
//!
// Copyright INRIA
[lhs,rhs]=argn(0)
if size(den,'*')<>1 then  error(54,2);end
[ns,ne]=size(num);
if type(num)==1 then 
  if type(den)==1 then
    sl=syslin([],[],[],[],num./den,[])
    return
  else
    num(1,1)=poly(num(1,1),varn(den),'c'),
  end
end
nd=degree(den);
// normalization
dnd=coeff(den,nd);den=den/dnd;num=num/dnd
// D(s)
for l=1:ns,
  for k=1:ne,
   [nl,dl]=pdiv(num(l,k),den),
   num(l,k)=nl,d(l,k)=dl,
 end,
end
if maxi(degree(d))==0 then d=coeff(d),end
//matrices a b and c
if nd<>0 then
 den=coeff(den);c=coeff(num,0:nd-1)
 a=[];
 for k=1:nd,a=[a,-den(k)*eye(ne,ne)];end
 a=[0*ones((nd-1)*ne,ne),eye(ne*(nd-1),ne*(nd-1));a];
 b=[0*ones((nd-1)*ne,ne);eye(ne,ne)]
else
 a=[];b=[];c=[]
end;
[n,n]=size(a);
sl=syslin([],a,b,c,d,0*ones(n,1))