Discrete-time equivalent systems example from matlab: the cd command Create the -time system using the tf command and then generate the discrete-time equivalents using the cd command. We use this command to generate the Tustin (linear transformation) equivalent discrete-time equivalent of the -time system preceded by a zero-order hold. We generate three such discrete-time equivalents with sampling times T =.5,.5,.5 seconds.that is sampling at, and Hertz. >> csys = tf(,[ ]) csys = ----- s + Continuous-time transfer function. >> dsys_slow = cd(csys,.5, ) dsys_slow =. z +. ----------- z -.6 Sample time:.5 seconds >> dsys_mid = cd(csys,.5, ) dsys_mid =.49 z +.49 ------------------- z -.95 Sample time:.5 seconds >> dsys_fast = cd(csys,.5, ) dsys_fast =.494 z +.494 --------------------- z -.995 Sample time:.5 seconds
Step responses Next we generate five-second step responses for each system, recognizing that matlab itself is computing a discretized solution for the -time response. We use the step function generate the discrete time-vectors using the sampling time parameters from tf. >> tcts = [:.:5.] ; >> ycts = step(csys,tcts); >> [yslow,tslow] = step(dsys_slow,5.); >> [ymid,tmid] = step(dsys_mid,5.); >> [yfast,tfast] = step(dsys_fast,5.); >> plot(tcts,ycts,tslow,yslow, o,tmid,ymid, *,tfast,yfast, + );shg >> title( Step responses ) >> xlabel( );ylabel( ); >> legend(, Hz sampling, Hz sampling, Hz sampling ) >> print -dpdf Steps.pdf >> print -dpdf StepsZoom.pdf Step responses Step responses.9.84.8.8.7.8.6.5.4.8.8.79... Hz sampling Hz sampling Hz sampling.5.5.5.5 4 4.5 5.78.77.76.75 Hz sampling Hz sampling Hz sampling.44.46.48.5.5.54.56 Sinusoidal responses at differing frequencies Frequency 4π radians per second,. Hz We have the following discrete-time equivalent frequencies. Sample rate discrete frequency (per sample) π Hz =.π Hz =.π Hz =. >> sin_slow = sin(4*pi/*tslow);
>> sin_mid = sin(4*pi/*tmid); >> sin_fast = sin(4*pi/*tfast); >> sin_cts = sin(4*pi/*tcts); >> ys_slow = lsim(dsys_slow,sin_slow,tslow); >> ys_mid = lsim(dsys_mid,sin_mid,tmid); >> ys_fast = lsim(dsys_fast,sin_fast,tfast); >> ys_cts = lsim(csys,sin_cts,tcts); >> plot(tcts,ys_cts,tslow,ys_slow, o,tmid,ys_mid, *,tfast,ys_fast, + );shg >> title( Slow sine responses ) >> xlabel( );ylabel( ); >> legend(, Hz sampling, Hz sampling, Hz sampling ) >> print -dpdf SlowSine.pdf >> print -dpdf SlowSineZoom.pdf.4. Slow sine responses Hz sampling Hz sampling Hz sampling.. Slow sine responses Hz sampling Hz sampling Hz sampling..8..6.4 -... -..8 -..5.5.5.5 4 4.5 5.6.9.94.96.98..4 Frequency 4π radians per second,.hz We have the following discrete-time equivalent frequencies. Sample rate discrete frequency (per sample) Hz aliased π Hz =.π Hz = >> sinf_mid = sin(4*pi/*tmid); >> sinf_fast = sin(4*pi/*tfast); >> sinf_cts = sin(4*pi/*tcts); >> ysf_mid = lsim(dsys_mid,sinf_mid,tmid); >> ysf_fast = lsim(dsys_fast,sinf_fast,tfast); >> ysf_cts = lsim(csys,sinf_cts,tcts); >> plot(tcts,ysf_cts,tmid,ysf_mid, *,tfast,ysf_fast, + );shg >> title( Midrange sine responses ) >> xlabel( );ylabel( ); >> legend(, Hz sampling, Hz sampling ) >> print -dpdf MidSine.pdf
>> print -dpdf MidSineZoom.pdf.5.4 Midrange sine responses Hz sampling Hz sampling.5. Midrange sine responses Hz sampling Hz sampling..5....5 -.5 -. -. -.5 -. -. -..5.5.5.5 4 4.5 5 -.5.98..4.6.8...4.6.8 Frequency 4π radians per second,.hz We have the following discrete-time equivalent frequencies. Sample rate discrete frequency (per sample) Hz aliased Hz aliased.π Hz = >> sins_fast=sin(4*pi/*tfast); >> sins_cts=sin(4*pi/*tcts); >> yss_fast=lsim(dsys_fast,sins_fast,tfast); >> yss_cts=lsim(csys,sins_cts,tcts); >> plot(tcts,yss_cts,tfast,yss_fast, + );shg >> title( Fast sine responses ) >> xlabel( );ylabel( ); >> legend(, Hz sampling ) >> print -dpdf FastSine.pdf >> print -dpdf FastSineZoom.pdf Frequency 4π radians per second,.hz; with frequency pre-warping Let us try to match the responses at this high frequency π/ c per sample by using Tustin s method with frequency pre-warping. This is done by scaling the s-plane by a factor f so that the scaled s-domain point, s = jfω, maps to the correct z-domain point, z = e jωt. The bilinear transformation of Tustin has s T z z + and thus z + T s T s.
# - 5 4 Fast sine responses Hz sampling # -.5 Fast sine responses Hz sampling.5.5 -.5 - - - -.5 - -.5.5.5.5 4 4.5 5..4.5.6.7.8.9. If we use the above elements, this means solving This has the solution f = [ cos ωt ] ωt sin ωt. z = e jωt = + jf T ω jf T ω. We find the pre-warped system by substituting for s as above into s+. dsys warp(z) = = = = z z+ +, z + z + z +, ( + + z + ) z + ( z + z + / +/. ), >> omt = *pi/ % omega T value in z-domain omt =.944 >> f=*(-cos(omt))/omt/sin(omt) % f-value for pre-warping the s-domain f =.654 >> tft = /f/.5 % / value tft =
4.899 >> dsys_warp = tf([ ]/(+tft),[ (-tft)/(+tft)],.5) % as is the formula above dsys_warp =.48 z +.48 --------------------- z -.998 Sample time:.5 seconds Now try the fast sinusoid input signal again. We see that the pre-warping matches very well. # - 5 4 # -.5.5 -.5 - - -.5 - - - 5 5 5 5 4 45 5 9.45 9.44 9.445 9.45 9.455 9.46 My mistake in interpreting the figure in class was to fail to recognize the period-three nature of the fast sinusoid it really only takes on three distinct value. If we alter the frequency a little we see a different plot where the intercept points move to different parts of the input sinusoid. >> *pi/ ans =.944 >> sinsd_cts = sin(4*tcts); >> sinsd_fast = sin(4*tfast); >> yssd_cts=lsim(csys,sinsd_cts,tcts); >> yssd_fast=lsim(dsys_fast,sinsd_fast,tfast); >> yssd_warp=lsim(dsys_warp,sinsd_fast,tfast); >> plot(tcts,yssd_cts,tfast,yssd_fast, o,tfast,yssd_warp, k+ );shg But what happens to the step response of this pre-warped system? It all goes down the toilet at dc ( c per sample) because it fits at π/ c per sample and we can only pre-warp to fit at one point on the unit circle.
# - 5 4.5 # -.5.5 -.5 - - -.5 - - - 8.7 8.8 8.9 9 9. 9. 9. 9.4 9.5 -.5 8.8 8.84 8.86 8.88 8.9 8.9 8.94 8.96 8.98 9 9..9 Step Response pre-warped.8.7.6 Amplitude.5.4....5.5.5.5 4 4.5 5 Time (seconds)