You are on page 1of 8

% Issue the commands to perform the outlined tasks for % Matlab Problem Set #9 Prob. 1.

% sys1=tf([1,0],[1,2,3]), % Enter the transfer function of the system from % Problem 6.4-1. Transfer function: s ------------s^2 + 2 s + 3 z1=zero(sys1), % Examine the finite zeros of this system. % origin! z1 = 0 p1=pole(sys1), % Examine the location of the two poles of this system. p1 = -1.0000 + 1.4142i -1.0000 - 1.4142i % With a zero at the origin, and two poles (which happen to be complex % conjugates), this system should produce a band-pass filtering type of % behavior. % % Problem Set #9, Problem 1 (b). % Plot the Bode plot of the given system. bode(sys1) % The magnitude response does exhibit a bandpass filter shape. % The passband's center frequency (peak value) is around 2 radians/second. % % Part (c): Generate the step response and the impulse response for this % system. figure(2) step(sys1), % Step Response. % The ringing behavior is a consequence of the complex conjugate poles. % The final value of the step response goes to zero, since there is no DC % gain. % Remember, the system had a zero at the origin or at DC. % figure(3) impulse(sys1), % Examine the impulse response. % This impulse response does seem consistent with the H[s] transfer function. % The response decays after about 5 seconds, which is consistent with the % real part of the poles equalling 1.0 or providing a time constant of % 1 second. % % Part (d): % From the Bode plot, I would expect the harmonics close to omega equal to % 2 rad/sec. % to be passed more favorably than any of the other harmonics. Based on It should be at

% Figure 6.2(b), the harmonics are at 2, 4, 6, etc. rad/sec. Thus, I would % expect the output response to be mostly made up of the sinusoidal component % at 2 rad/sec. % The DC component of the input (omega = 0) should be blocked by the system's % zero at the origin. The input waveform's second harmonic at 4 rad/sec is % about half the size of the 1st harmonic's magnitude at 2 rad/sec. In % addition, the system's frequency response indicates that the gain near % 4 rad/sec is several dB down from the frequency response at 2 rad/sec. % Thus, I would expect the output response to look somewhat like a sinusoidal % waveform with no DC component, % with the sinusoidal output dominated by the 2 rad/second harmonic. % % Part (e): % Generate the actual system response to the periodic waveform in % Figure 6.2(a). t_period=0:0.01:pi; % Define a time interval for one period. x_period=exp(-0.5*t_period); % Create the waveform for one period of time. x1=x_period(1,1:(end-1)); % Remove the last term in the vector "x_period". % % I have reduce the number of components in the vector "x_period" by one. % The removed component was at the tail end of the "x_period" waveform. % This removal of the last term in "x_period" allows me to combine several % of these one period waveforms to generate the waveform in Figure 6.2a. x=[x1,x1,x1,x1,x1,x1]; % Combine 6 periods into a single waveform. time=0:0.01:6*pi; % Create a time vector that almost works with "x". % I will need to remove or discard the last element in "time" to make % the "time" vector compatible with the "x" vector in terms of the number % of elements in each vector. time=time(1,1:(end-1)); % Remove the last term in the "time" vector. % % The system has already been defined in an earlier part of this problem. % The system has been call "sys1". I will redisplay this system's % transfer function. sys1, % Remind myself of the system. Transfer function: s ------------s^2 + 2 s + 3 y=lsim(sys1,x,time); % Generate the system's output response to the input % waveform "x". figure(4), % Introduce a new figure window to not overwrite earlier work. plot(time,x,'k-',time,y,'k-.') % Display input and output on same plot. legend('Input','Output') % Label the two different waveforms. title('Bandpass Filter Behavior') xlabel('Time'),ylabel('Waveforms') % The output response does not have a DC component and is somewhat close % to a sinusoidal waveform, which is what was expected! diary off

Display the figure windows from the above diary file.

Figure 1 (below): Bode plot of the system.
Bode Diagram 0 -10
Magnitude (dB) Phase (deg)

-20 -30 -40 -50 -60 90 45 0 -45 -90 10
-2

10

-1

10

0

10

1

10

2

Frequency (rad/sec)

Figure 2 (below): Step Response.
Step Response 0.3

0.25

0.2

Amplitude

0.15

0.1

0.05

0

-0.05

0

1

2

3

4 Time (sec)

5

6

7

8

Figure 3 (below): Impulse Response.
Impulse Response 1

0.8

0.6

Amplitude

0.4

0.2

0

-0.2

-0.4

0

1

2

3 Time (sec)

4

5

6

Figure 4 (below): Input Waveform and Output Response of System.
Bandpass Filter Behavior 1.2 Input Output

1

0.8

Waveforms

0.6

0.4

0.2

0

-0.2

0

2

4

6

8

10 Time

12

14

16

18

20

Matlab Problem Set #9, Problem 2.
% Issue commands to help check the answer obtained in Problem 7.1-4(a). % Problem 7.1-4(a) concerns computing the Fourier Transform of a time % limited exponentially decaying waveform. % I have arbitrarily decided to use an exponential decay value of 0.5 % and a time duration for the waveform of 2.0 seconds. % For these choices, the exponential decay rate provides a time constant of % (1/0.5) or 2 seconds, which is the length of time I have decided to allow % the waveform to be non-zero. syms t w % Define "t" and "w" as a symbolic time and % frequency variable, respectively. a=0.5;T=2; % Assign numerical values for the decay rate and waveform % time duration. % Compute the Fourier Transform symbolically. X=int(exp(-a*t)*exp(-j*w*t),t,0,T), % Perform the symbolic integration. X = (2*((1/exp(2*w*i))/exp(1) - 1)*i)/(2*w - i) pretty(X), % Display a "pretty" version of the Fourier Transform result. / 1 \ | ---------| | exp(2 w i) | 2 | ---------- - 1 | i \ exp(1) / ---------------------2 w - i % The above Fourier Transform can be made to equal the answer in % Problem 7.1-4(a) % if the above expression is multiplied by "1". In this case, a good choice % for the number "1" is to use (0.5i/0.5i), where "i" is the square root % of -1.0. The variable "i" in the above Fourier Transform is sqrt(-1). diary off

Matlab Problem Set #9, Problem 3.
% Generate the Fourier Transform of a decaying exponential that is non-zero % for all positive values of time including t=0. syms t % Define "t" as a symbolic time variable. h=exp(-0.5*t)*heaviside(t), % Define the decaying exponential for t>=0. h = heaviside(t)/exp(t/2) % The "heaviside" function behaves (acts) like the unit step. H=fourier(h), % Compute the Fourier Transform of the exponential function. H = 1/(1/2 + w*i) % This Fourier Transform is consistent with the Fourier Transform of a % decaying exponential waveform that is defined for non-negative values % of time. % One can compare this Fourier Transform with the Laplace Transform % of the same decaying exponential. The Fourier Transform can be obtained % by replacing "s" in the Laplace Transform H[s] with "jw", % since the decaying exponential corresponds to a stable waveform, i.e., % the waveform is absolutely integrable or the region of convergence of the % Laplace Transform contains the imaginary axis (jw-axis) or % the poles of the Laplace Transformed waveform are in the closed, % Left-Half Plane. % In the s-plane pole/zero diagram associated with this waveform, the pole % of the Laplace Transformed waveform is located at s=-0.5 for the specific % decay rate selected for this example. diary off