forked from rutup1595/gui-codes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzpkdata.sci
83 lines (61 loc) · 2.22 KB
/
zpkdata.sci
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
//author :Rutuja moharil
// zero pole gain plot
//returns the zeros z, poles p, and gain(s) k and sample time Ts of the zero-pole-gain SISO and MIMO model sys.
function[x,t,o,dt]= zpkdata(sys,varargin)
n=length(varargin); //length of the input vairiable matrix
select typeof(sys) //check the system type
case "state-space"
sys=ss2tf(sys); //convert state space to tf model
end;
if (n==1) then //for SISO systems
if((strcmpi(varargin(1),'v'))==0) then //check whether the string 'v' is entered
x=roots(sys.num); //extracting the zeroes
t=roots(sys.den); // extracting the poles
[y,o]=factors(sys.num); //extracting gain
o=o;
dt=sys.dt // extracting sampling time
else
error('specify proper variable input')
end
else if(n==0) //for MIMO and array of SISO systems
m = size(sys);
nd = length(m);
if(nd>2) then
x=cell(size(sys,'r'),size(sys,'c'),size(sys,3))
y=cell(size(sys,'r'),size(sys,'c'),size(sys,3))
o=cell(size(sys,'r'),size(sys,'c'),size(sys,3))
for i=1:size(sys,'r')
for j=1:size(sys,'c')
for k=1:size(sys,3)
x(i,j,k).entries=(roots(sys(i,j,k).num));
//extracting the zeroes
t(i,j,k).entries=roots(sys(i,j,k).den);
// extracting the poles
// [y,m]=factors(n);
[y,nn]=factors(sys(i,j,k).num);
o(i,j,k).entries=nn;
// b= t(:,:,l);
// c=k(:,:,l);
dt=sys.dt;
end
end
end
else
x=cell(size(sys,'r'),size(sys,'c'))
t=cell(size(sys,'r'),size(sys,'c'))
o=cell(size(sys,'r'),size(sys,'c'))
for i=1:size(sys,'r')
for j=1:size(sys,'c')
x(i,j).entries=roots(sys(i,j).num);
t(i,j).entries=roots(sys(i,j).den);
[y,nn]=factors(sys(i,j).num);
o(i,j).entries=nn;
dt=sys.dt
// b= t(:,:,l);
// c=k(:,:,l);
end
end
end
end
end
endfunction