Question 6 Here is some Matlab code that uses this system to illustrate the Matlab functions tf, zpk, zero, pole, tfdata
Posted: Fri Jul 01, 2022 5:34 am
Question 6 Here is some Matlab code that uses this system to illustrate the Matlab functions tf, zpk, zero, pole, tfdata, isstable, printsys, and pzmap: 8P2a 8 Use the transfer function 8 8H(s) = 2 (s+1) (8-2) (s+2) (s+3) (S-1) 8 to illustrate the Matlab functions tf, zpk, zero, 8 pole, tfdata, isstable, printsys, and pzmap. clear; z = [-1 2]; - Re(s) > 1 [-2 -3 1]; P g = 2; H1 zpk (z,p,g) 8zeros (roots of numerator) poles (roots of denominator) transfer function gain zero-pole-gain system model
* convert to transfer function system model * Get the numerator and denominator polynomial coefficients [numer, denom] = tfdata (H1, 'v') Do it again with the other model 8 [numer, denom] = tfdata (H2, 'v') H2 = tf (H1) 8 Compute a transfer function system model from the numer and denom coefficients 8 H3 = tf (numer, denom) H3 is the same as H1 8 Convert to zero-pole-gain system model 8 H4 = zpk (H3) H4 is the same as H1 Use the numer and denom coefficients to 8 print the transfer function to the 8 Matlab command window printsys (numer, denom) Use the pole function to get the poles 8 from system models H1 and H2 8 P = pole (H1) p = pole (H2) 8 same result as the line above Use the zero function to get the zeros 8 from system models H1 and H2 8 z zero (H1) z = zero (H2) 8 same result as the line above 8 8 Use pzmap to get the poles and zeros 8 [p z] = pzmap (H1) [p z]= pzmap (H2) same result as the line above. 8 & Generate a pole-zero plot in three different ways 8 figure (1); pzmap (H1) ; figure (2); pzmap (H2); figure (3); pzmap (numer, denom); 8 8 Use isstable to show that the system is unstable 8 isstable (H1) 8 * Use residue to compute a partial fraction expansion. Notice that we don't have to multiply out the denominator by hand.
[r p k] = residue (numer, denom) Let's see what variables we have: (a) Type in the code and run it. You can type it in line-by-line at the command prompt or you can create an m-file. Don't forget to include the pole-zero plots in your turn-in file. (b) Use the [r p k] values returned by residue to find the impulse response h(t).
* convert to transfer function system model * Get the numerator and denominator polynomial coefficients [numer, denom] = tfdata (H1, 'v') Do it again with the other model 8 [numer, denom] = tfdata (H2, 'v') H2 = tf (H1) 8 Compute a transfer function system model from the numer and denom coefficients 8 H3 = tf (numer, denom) H3 is the same as H1 8 Convert to zero-pole-gain system model 8 H4 = zpk (H3) H4 is the same as H1 Use the numer and denom coefficients to 8 print the transfer function to the 8 Matlab command window printsys (numer, denom) Use the pole function to get the poles 8 from system models H1 and H2 8 P = pole (H1) p = pole (H2) 8 same result as the line above Use the zero function to get the zeros 8 from system models H1 and H2 8 z zero (H1) z = zero (H2) 8 same result as the line above 8 8 Use pzmap to get the poles and zeros 8 [p z] = pzmap (H1) [p z]= pzmap (H2) same result as the line above. 8 & Generate a pole-zero plot in three different ways 8 figure (1); pzmap (H1) ; figure (2); pzmap (H2); figure (3); pzmap (numer, denom); 8 8 Use isstable to show that the system is unstable 8 isstable (H1) 8 * Use residue to compute a partial fraction expansion. Notice that we don't have to multiply out the denominator by hand.
[r p k] = residue (numer, denom) Let's see what variables we have: (a) Type in the code and run it. You can type it in line-by-line at the command prompt or you can create an m-file. Don't forget to include the pole-zero plots in your turn-in file. (b) Use the [r p k] values returned by residue to find the impulse response h(t).