EE-450 Project 2

.pdf

School

Grossmont College *

*We aren’t endorsed by this school

Course

450

Subject

Electrical Engineering

Date

May 25, 2024

Type

pdf

Pages

12

Uploaded by queenhabibi715

EE-450 Project-2 Frequency-Domain Analysis of Discrete-Time Systems Maria Dawood 822489441 March rd, 2024
1. Use MATLAB to find the DTFT of and plot its magnitude and phase 𝑥[𝑛] = (0. 5) 𝑛 𝑢[𝑛] for . You need to use “freqz” function in MATLAB (do not forget to use 0 ≤ ω ≤ π “unwrap” function!) This questions instructs us to use MATLAB to calculate and visualize the Discrete Time Fourier Transform (DTFT) of the given signal . This is accomplished by 𝑥[𝑛] = (0. 5) 𝑛 𝑢[𝑛] employing the “freqz” function to compute the DTFT and then plotting both the magnitude and phase of the resulting transform. The magnitude plot reveals how much of each frequency component is present in the signal, while the phase plot shows the phase shift that each component undergoes. Using the “unwrap” function ensures that the phase plot is continuous, making it easier to interpret. This process is crucial for understanding the frequency characteristics of the signal, which is essential in fields like signal processing and communications. Matlab Code: % Initialize the signal x[n] index_n = 0:50; % Setting the range for n x_signal = (0.5).^index_n .* heaviside(index_n); % Calculating the values for the signal % Calculate the Discrete Time Fourier Transform (DTFT) of x[n] omega = linspace(0, pi, 1000); % Defining the omega range X_dtft = freqz(x_signal, 1, omega); % DTFT calculation magnitudeX = abs(X_dtft); % Magnitude of the DTFT phaseX = unwrap(angle(X_dtft)); % Phase of the DTFT % Since there are no denominator coefficients in x[n], we use 1. figure(1) % Display the magnitude and phase of the DTFT subplot(2,1,1); plot(omega, magnitudeX); xlabel( 'Frequency (rad/sample)' ); ylabel( 'Magnitude' ); title( 'DTFT Magnitude of x[n]' ); grid on % minor grid is not available in all MATLAB versions, using 'on' for broader compatibility subplot(2,1,2); plot(omega, phaseX); xlabel( 'Frequency (rad/sample)' ); ylabel( 'Phase (rad)' ); title( 'DTFT Phase of x[n]' ); grid on % Using 'grid on' for compatibility
Output: 2. Find the impulse response of the following system and plot its frequency response (both magnitude and phase. To determine the system's impulse response, the input signal x[n] is designated as the delta function, characterized by a value of 1 at n = 0 and 0 at all other values. The resulting output from the system, denoted as h[n], will represent the impulse response of the system. When the difference equation becomes: 𝑥[𝑛] = δ[𝑛] ℎ[𝑛] + 0. 06ℎ[𝑛 − 1] + 0. 03ℎ[𝑛 − 2] − 0. 01ℎ[𝑛 − 1] = δ[𝑛] + 2δ[𝑛 − 1] − δ[𝑛 − 2] To compute h[n], we can employ the z-transform technique. By applying the z-transform to each side of the equation, we obtain: 𝐻(𝑧) + 0. 06 𝑧 −1 𝐻(𝑧) + 0. 03 𝑧 −2 𝐻(𝑧) − 0. 01 𝑧 −3 𝐻(𝑧) = 1 + 2 𝑧 −1 − 𝑧 −2 Then solving for H(z), we then will get the following:
𝐻(𝑧)(1 + 0. 6𝑧 −1 + 0. 03𝑧 −2 − 0. 01𝑧 −3 ) = (1 + 2𝑧 −1 − 𝑧 −2 ) 𝐻(𝑧) = (1+2𝑧 −1 −𝑧 −2 ) (1+0.6𝑧 −1 +0.03𝑧 −2 −0.01𝑧 −3 ) 𝐻(𝑧) = (𝑧 3 +2𝑧 2 −𝑧) (𝑧 3 +0.6𝑧 2 +0.03𝑧−0.01) To determine h[n], the inverse z-transform can be applied. By breaking down H(z) into simpler fractions through partial fraction decomposition, we can then reference a table to find the corresponding inverse z-transforms for these simpler terms. The decomposition process is as follows: 𝐻(𝑧) = 1 − 0.438889 (−0.1+𝑧) 3.02222 (0.2+𝑧) + 4.86111 (0.5+𝑧) 𝐻(𝑧) = 1 − 0.438889𝑧 −1 (1−0.1𝑧 −1 ) 3.02222𝑧 −1 (1+0.2𝑧 −1 ) + 4.86111𝑧 −1 (1+0.5𝑧 −1 ) By taking the inverse z-transform and using the table we then will have: ℎ[𝑛] = 𝑢[− 𝑛] + (1 − 𝑢[− 𝑛])[10 −𝑛−5 (− 972222(− 5) 𝑛 + 755555(− 1) 𝑛 2 𝑛+1 − 438889)] To visualize the system's frequency response, we apply the Fourier transform to the impulse response. In MATLAB, the “abs” and “angle” functions are utilized to calculate the magnitude and phase of the frequency response, respectively. Below is the MATLAB script to execute the computation and plotting of the frequency response: Matlab Code: % Initialize the impulse response h[n] index = 0:50; h = heaviside(-index) + (1 - heaviside(-index)) .* (10.^(-index - 5) .* (-972222 .* (-5).^index + 755555 .* ((-1).^index))); % Calculate and display the frequency response frequency = linspace(0, pi, 1000); H_freq = freqz(h, 1, frequency); magnitudeH = abs(H_freq); phaseH = unwrap(angle(H_freq)); figure(2) subplot(2,1,1); plot(frequency, magnitudeH); xlabel( 'Frequency (rad/sample)' ); ylabel( 'Magnitude' ); title( 'Frequency Response Magnitude' );
grid on ; % Changed to 'grid on' for compatibility subplot(2,1,2); plot(frequency, phaseH); xlabel( 'Frequency (rad/sample)' ); ylabel( 'Phase (rad)' ); title( 'Frequency Response Phase' ); grid on ; % Changed to 'grid on' for compatibility Output: 3. Find the output of the system to x[n] given in part 1 using two different methods: a. Find it directly using “filter” function (initial conditions are zero). b. Find it by using the frequency response method (DFTF and IDTFT). You can use “invfreqz” to find the inverse DTFT a) I will first be using the filter function in matlab to find the output system of x[n]. Matlab Code: % Specify the input signal x[n] sample_points = 0:99; input_sequence = (0.5).^sample_points .* heaviside(sample_points); % Establish the impulse response of the system h[n] impulse_response = heaviside(-sample_points) + (1 - heaviside(-sample_points)) .* (10.^(-sample_points - 5) .* (-972222 * (-5).^sample_points + 755555 .* ((-1).^sample_points))); % Determine the system's output using the filter function
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help