forked from rutup1595/gui-codes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsigmaplot.sci
87 lines (73 loc) · 3.45 KB
/
sigmaplot.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
84
85
86
87
function H=sigmaplot(varargin)
[lhs,rhs]=argn(0);
x=logspace(-3,3);
//________________if freq vector or freqfinal is given//__________________//________________//
if rhs > 1 then
if typeof(varargin($)) == 'constant' then
if ~isreal(varargin($)) then
error("sigma:The freq values must be real and positive")
end
if size(varargin($)) == [1 2] then
if varargin($) <= 0 then
error(msprintf(gettext("%s: The final time value must be a positive real number.\n"),"sigma"))
end
if(varargin($)(1)>=varargin($)(2)) then
error("sigma:The frequency interval must be specified as {WMIN,WMAX} where WMIN and WMAX are positive frequencies satisfying WMIN<WMAX.");
end
x=varargin($)(1):0.01:varargin($)(2);
elseif (isequal(size(varargin($)),[1 2]) == %f & size(varargin($),'*')<>1) then
x=varargin($);
elseif (size(varargin($),'*')==1) then
error("sigma:The frequency interval must be specified as {WMIN,WMAX} where WMIN and WMAX are positive frequencies satisfying WMIN<WMAX.");
end
end
end
//______________________________________________________________//
CIindex=1;
//____________PLOTS__________________________________//
if lhs==1 then
for i=1:rhs
CIindex=CIindex+1;
if or(typeof(varargin(i))==['string','boolean']) then
continue;
end
//__________________SiSo system & MIMO systems__________________________//
if(or(typeof(varargin(i))==['rational','state-space']) & (i==rhs | typeof(varargin(i+1))<>'boolean' )) then
y=svplot(varargin(i),x);
y=20*log10(y);
if (i<>rhs & typeof(varargin(i+1))=='string') then
plot(x,y,varargin(i+1));
else
plot(x,y);
hh=gce();
hh.children.foreground=CIindex;
end
//______________.siso arrays.__________________________//
elseif(or(typeof(varargin(i))==['rational','state-space']) & (typeof(varargin(i+1))=='boolean' )) then
if(varargin(i+1)<>%T) then
error("Sigma: Siso array must be followed with boolean input %T");
end
xx=size(varargin(i),'r');
yy=size(varargin(i),'c');
zz=size(varargin(i),3);
for ii=1:xx
for j=1:yy
for k=1:zz
y=svplot(varargin(i)(ii,j,k),x);
y=20*log10(y);
if (i<>rhs-1 & typeof(varargin(i+2))=='string') then
plot(x,y,varargin(i+2));
else
plot(x,y);
hh=gce();
hh.children.foreground=CIindex;
end
end
end
end
end
end
end
xtitle("singular values","Frequency(rad/s)","Singular Values(dB)");
H=gca();
endfunction