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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) INRIA -
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
function [sl]=syslin(domain,a,b,c,d,x0)
[lhs,rhs]=argn(0)
//
// check domain
select type(domain)
case 1 then //sampled system
if size(domain,"*")<=2 then
tp=domain
else
error(msprintf(gettext("%s: Wrong size for input argument #%d: A scalar expected.\n"),"syslin",1))
end
z="z"
case 10 //continuous or discrete
if size(domain,"*")<>1 then
error(msprintf(gettext("%s: Wrong size for input argument #%d: A string expected.\n"),"syslin",1))
end
domain=part(domain,1)
select domain
case "c" then
z="s"
case "d" then
z="z"
else
error(msprintf(gettext("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"), "syslin",1,"''c'',''d''"))
end;
else
error(msprintf(gettext("%s: Wrong type for input argument #%d: String, Scalar or empty matrix expected.\n"),"syslin",1))
end;
//============================================================================
if rhs==2 then //syslin(domaine,sys)
if typeof(a)=="state-space" | typeof(a)=="rational" then
sl=a;
sl("dt")=domain
else
error(msprintf(gettext("%s: Wrong type for input argument #%d: Linear state space or a transfer function expected.\n"),"syslin",2))
end
//============================================================================
elseif rhs==3 then // syslin(domaine,num,den)
num=a;den=b
if type(num)>2 then
error(msprintf(gettext("%s: Wrong type for input argument #%d: Polynomial array expected.\n"),"syslin",2))
end
if type(den)>2 then
error(msprintf(gettext("%s: Wrong type for input argument #%d: Polynomial array expected.\n"),"syslin",3))
end
if or(size(num)<>size(den)) then
error(msprintf(gettext("%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n"),"syslin",2,3))
end
if type(num)==2 & type(den)==2 then
if varn(num)<>varn(den) then
error(msprintf(gettext("%s: Incompatible input arguments #%d and #%d: Same formal variable names expected.\n"),"syslin",2,3))
end
end
if type(num)==1 then
num=num*poly(1,z,"c")
end
if type(den)==1 then
den=den*poly(1,z,"c")
end
sl=rlist(varn(num,z),varn(den,z),domain)
//============================================================================
elseif rhs>3 then // syslin(domaine,A,B,C [,D [X0]])
if type(a)<>1 then
error(msprintf(gettext("%s: Wrong type for input argument #%d: Array of floating point numbers expected.\n"),"syslin",2))
end
[ma,na]=size(a);
if ma<>na then
error(msprintf(gettext("%s: Wrong size for input argument #%d: Square matrix expected.\n"),"syslin",2))
end
if type(b)<>1 then
error(msprintf(gettext("%s: Wrong type for input argument #%d: Array of floating point numbers expected.\n"),"syslin",3))
end
[mb,nb]=size(b);
if na<>mb&mb<>0 then
error(msprintf(gettext("%s: Incompatible input arguments #%d and #%d: Same row dimensions expected.\n"),"syslin",2,3));
end
if type(c)<>1 then
error(msprintf(gettext("%s: Wrong type for input argument #%d: Array of floating point numbers expected.\n"),"syslin",4))
end
[mc,nc]=size(c);
if na<>nc&nc<>0 then
error(msprintf(gettext("%s: Incompatible input arguments #%d and #%d: Same column dimensions expected.\n"),"syslin",2,4));
end
if rhs<6 then
x0=0*ones(na,1)
else
if type(x0)>1 then
error(msprintf(gettext("%s: Wrong type for input argument #%d: Array of floating point numbers expected.\n"),"syslin",6))
end
[mx,nx]=size(x0);
if mx<>na|nx<>min(na,1) then
error(msprintf(gettext("%s: Incompatible input arguments #%d and #%d: "+..
"number of elements of #%d must match the column dimension of #%d\n"),"syslin",6,1,6,1));
end
end
if rhs<5 then
d=0*ones(mc,nb)
else
if type(d)>2 then
error(msprintf(gettext("%s: Wrong type for input argument #%d: Polynomial array expected.\n"),"syslin",5))
end
[md,nd]=size(d);
if c*b<>[] then
if mc<>md then
error(msprintf(gettext("%s: Incompatible input arguments #%d and #%d: Same row dimensions expected.\n"),"syslin",2,5));
end
if nb<>nd then
error(msprintf(gettext("%s: Incompatible input arguments #%d and #%d: Same column dimensions expected.\n"),"syslin",3,5));
end
end
end
sl=lsslist(a,b,c,d,x0,domain)
end
endfunction
|