summaryrefslogtreecommitdiff
path: root/3432/CH3/EX3.23/Ex3_23.sce
blob: 613d47c192343261d9125115cbf2eee309bd3939 (plain)
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
//Example 3.23 Oscillatory Time Response

xdel(winsid())//close all graphics Windows
clear;
clc;
//------------------------------------------------------------------
//Transfer function of second order underdamped system
numH=[1 2];
denH=[5 2 1];
Ns=poly(numH,'s','coeff');
Ds=poly(denH,'s','coeff');
sysH=syslin('c',Ns/Ds);

//damping factor (xi) and natural frequency (wn)
[wn xi]=damp(sysH);
wn=wn(1);
xi=xi(1);
sigma=xi*wn;
wd=wn*sqrt(1-xi^2);

//denominator in sigma-wn form H(s)=H1(s)+H2(s)
s=%s;
p=(s+sigma)^2+wd^2
temp=polfact(Ns);
k=temp(1),zr=temp(2);
h1=(s+sigma)/p;
h2=-((s+sigma)-temp(2))*wd/p;
H1s=syslin('c',k*h1);
H2s=syslin('c',k*h2/wd);

// responses with exponential envelope
Env=syslin('c',k/(s+sigma));
t=0:0.02:10;
//impulse response
ht=csim('impuls',t,sysH);
envt=csim('impuls',t,Env);
envt_neg=csim('impuls',t,-Env);

plot(t,ht)
plot(t,envt,'r--')
plot(t,envt_neg,'r--')
exec .\fig_settings.sci; //custom script for setting figure properties
title('Impulse response of the underdamped system','fontsize',3)
xlabel('Time t (sec.)','fontsize',2)
ylabel('h(t)','fontsize',2)
xset("font",1,2)
xstring(1,0.75,"$e^{-\sigma t}$",0,0)
xstring(1,-0.85,"$-e^{-\sigma t}$",0,0)
//------------------------------------------------------------------