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 132 133 134 135 136
|
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2008 - INRIA - Serge Steer
//
// This file is distributed under the same license as the Scilab package.
// =============================================================================
// <-- TEST WITH GRAPHIC -->
// <-- ENGLISH IMPOSED -->
function r=checkbode(h,leg)
fig=gcf();
r=%t
ap=fig.children(1);
am=fig.children(2);
if am.log_flags<>'lnn' then r=%f;return,end
if or(am.axes_visible<>["on","on","on"]) then r=%f;return,end
if ap.log_flags<>'lnn' then r=%f;return,end
if or(ap.axes_visible<>["on","on","on"]) then r=%f;return,end
n=size(am.children($).children,'*')
if n<>size(h,1) then bugmes();quit;end
for k=1:n;
pm=am.children($).children(n+1-k);
pp=ap.children($).children(n+1-k);
if or(pm.data(:,1)<>pp.data(:,1)) then ;r=%f;return,end
[frq,rf]=repfreq(h(k,1),pm.data(:,1));[phi,d]=phasemag(rf);
if norm(d(:)-pm.data(:,2))> 1d-15 then r=%f;return,end
end
if argn(2)==2 then
if size(ap.children,'*')<2 then r=%f;return,end
if ap.children(1).type<>'Legend' then r=%f;return,end
if size(ap.children(1).links,'*')<>n then r=%f;return,end
if or(ap.children(1).text<>leg(:)) then r=%f;return,end
end
endfunction
s=poly(0,'s')
s =
s
n=1+s;d=1+2*s;
h=syslin('c',n,d)
h =
1 + s
-----
1 + 2s
sl=tf2ss(h);
sld=dscr(sl,0.01);
hd=ss2tf(sld);
[w,rf]=repfreq(h,0.01,100);
//continuous time
clf();bode(h);
if ~checkbode(h) then bugmes();quit;end
clf();bode(h,'h');
if ~checkbode(h,'h') then bugmes();quit;end
clf();bode(h,0.01,100);
if ~checkbode(h) then bugmes();quit;end
clf();bode(h,0.01,100,'h');
if ~checkbode(h,'h') then bugmes();quit;end
clf();bode(h,0.01,100,0.01)
if ~checkbode(h) then bugmes();quit;end
clf();bode(sl,0.01,100);
if ~checkbode(sl) then bugmes();quit;end
clf();bode(sl,0.01,100,0.01)
//continuous time SIMO
h=[h;h+1];sl=[sl;sl+1];
clf();bode(h);
if ~checkbode(h) then bugmes();quit;end
clf();bode(h,['h';'h+1']);
if ~checkbode(h,['h';'h+1']) then bugmes();quit;end
clf();bode(h,0.01,100);
if ~checkbode(h) then bugmes();quit;end
clf();bode(h,0.01,100,['h';'h+1']);
if ~checkbode(h,['h';'h+1']) then bugmes();quit;end
clf();bode(h,0.01,100,0.01)
if ~checkbode(h) then bugmes();quit;end
clf();bode(sl,0.01,100);
if ~checkbode(sl) then bugmes();quit;end
clf();bode(sl,0.01,100,0.01)
//discrete case
clf();bode(hd);
WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
if ~checkbode(hd) then bugmes();quit;end
clf();bode(hd,'h');
WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
if ~checkbode(hd,'h') then bugmes();quit;end
clf();bode(hd,0.01,100);
WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
if ~checkbode(hd) then bugmes();quit;end
clf();bode(hd,0.01,100,'h');
WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
if ~checkbode(hd,'h') then bugmes();quit;end
clf();bode(hd,0.01,100,0.01)
if ~checkbode(hd) then bugmes();quit;end
clf();bode(sld,0.01,100);
WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
if ~checkbode(sld) then bugmes();quit;end
clf();bode(sl,0.01,100,0.01)
//discrete case SIMO
hd=[hd;hd+1];sld=[sld;sld+1];
clf();bode(hd);
WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
if ~checkbode(hd) then bugmes();quit;end
clf();bode(hd,['h';'h+1']);
WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
if ~checkbode(hd,['h';'h+1']) then bugmes();quit;end
clf();bode(hd,0.01,100);
WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
if ~checkbode(hd) then bugmes();quit;end
clf();bode(hd,0.01,100,['h';'h+1']);
WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
if ~checkbode(hd,['h';'h+1']) then bugmes();quit;end
clf();bode(hd,0.01,100,0.01)
if ~checkbode(hd) then bugmes();quit;end
clf();bode(sld,0.01,100);
WARNING: calfrq: Frequencies beyond Nyquist frequency are ignored.
if ~checkbode(sld) then bugmes();quit;end
clf();bode(sl,0.01,100,0.01)
//bode given by precmputed freqency response
h=syslin('c',n,d)
h =
1 + s
-----
1 + 2s
clf();bode(h,0.01,100);
fig=gcf();
dp=fig.children(1).children($).children.data;
dm=fig.children(2).children($).children.data;
[w,rf]=repfreq(h,0.01,100);
clf(); bode(w,rf)
fig=gcf();
if norm(dp-fig.children(1).children($).children.data)>1d-13 then bugmes();quit;end
if norm(dm-fig.children(2).children($).children.data)>1d-13 then bugmes();quit;end
clf(); bode(w,20*log(abs(rf))/log(10),(180/%pi)*atan(imag(rf),real(rf)))
fig=gcf();
if norm(dp-fig.children(1).children($).children.data)>1d-13 then bugmes();quit;end
if norm(dm-fig.children(2).children($).children.data)>1d-13 then bugmes();quit;end
|