1 # GNUPLOT v3.6 beta multiplot script file
3 # Second Order System Characteristics
5 # D**2 + 2*zeta*wn*D + (wn**2)y = (wn**2)*x
9 # w frequency ratio (w/wn)
10 # wn natural frequency
11 # wd damped natural frequency
13 # mag(w) amplitude response
14 # phi(w) phase response
15 # wdwn damped natural frequency ratio
19 # Frequency domain magnitude response
22 # Time domain unit step response
23 # unit impulse response
26 # Created by: W. D. Kirby email: wdkirby@ix.netcom.com
28 # Released to the public domain with no warranty of any kind
31 set style function lines
41 # Plot Magnitude Response
42 set title "Second Order System Transfer Function - Magnitude"
43 mag(w) = -10*log10( (1-w**2)**2 + 4*(zeta*w)**2)
46 set xlabel "Frequency (w/wn)"
47 set ylabel "Magnitude (dB)" offset 1,0
48 set label 1 "Damping =.1,.2,.3,.4,.5,.707,1.0,2.0" at .14,17
63 set title "Second Order System Transfer Function - Phase"
65 set ylabel "Phase (deg)" offset 1,0
68 tmp(w) = (-180/pi)*atan( 2*zeta*w/(1-w**2) )
69 # Fix for atan function wrap problem
70 tmp1(w)= w<1?tmp(w):(tmp(w)-180)
71 phi(w)=zeta==1?(-2*(180/pi)*atan(w)):tmp1(w)
87 set title "Second Order System - Unit Step Response"
88 set ylabel "Amplitude y(wnt)" offset 1,0
89 set xlabel "Normalized Time (wnt)"
96 wdwn(zeta)=sqrt(1-zeta**2)
97 shift(zeta) = atan(wdwn(zeta)/zeta)
98 alpha(zeta)=zeta>1?sqrt(zeta**2-1.0):0
99 tau1(zeta)=1/(zeta-alpha(zeta))
100 tau2(zeta)=1/(zeta+alpha(zeta))
101 c1(zeta)=(zeta + alpha(zeta))/(2*alpha(zeta))
103 y1(wnt)=zeta==1?1 - exp(-wnt)*(wnt + 1):0
104 y2(wnt)=zeta<1?(1 - (exp(-zeta*wnt)/wdwn(zeta))*sin(wdwn(zeta)*wnt + shift(zeta))):y1(wnt)
105 y(wnt)=zeta>1?1-c1(zeta)*exp(-wnt/tau1(zeta))+c2(zeta)*exp(-wnt/tau2(zeta)):y2(wnt)
116 # Plot Impulse Response
118 set title "Second Order System - Unit Impulse Response"
119 y(wnt)=exp(-zeta*wnt) * sin(wdwn(zeta)*wnt) / wdwn(zeta)
132 pause -1 "Hit return to continue"
134 # Clean up: reset parameter defaults