Explore BrainMass
Share

# Fourier Analysis of system in MatLab

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Use the contfft program to identify the frequency response of a system from its inputs and outputs. The program contfft is shown below.Save it as contfft.m in your current
MATLAB directory as denoted at the top of the MATLAB window.

(a). Generate a random input signal x(t) in MATLAB by using the command rand. In particular, let x = rand(1000,1)-0.5. This will create a 1000 point vector of random numbers that represents the samples of x(t). Assume that the sampling period was T = 0.1, and create a corresponding time vector.

(b). Use MATLAB to determine a corresponding output y(t) for a particular system. In particular, type the command y=conv(exp(-t),x); to generate y(t). The array y will be 1999 elements long by virtue of how the convolution works. Use only the first 1000 elements. Plot x versus t and y versus t, and compare the two signals in terms of frequency content. (In the time domain, we characterize high-frequency content qualitatively by sharp transitions or quick motion of the signal.)

(c). Suppose that you have a spectrum analyzer available to identify the system using only the signals x(t) and y(t). Use contfft to compute the approximation X to X(&#969;) and an approximation of Y to Y(&#969;). Plot |X(&#969;)| and |Y(&#969;)| versus &#969;, and compare the difference in frequency content of these two signals. The frequency vector provided by the contfft command ranges from 0 to 62.769 rad/sec. However, since the sampling period is 0.1 sec, the Nyquist frequency is pi/T, 31.4159 rad/sec. Reconstruction cannot occur well for frequencies higher than this frequency. The frequencies above the Nyquist frequency can, on the other hand, be viewed as negative frequencies. A command fftshift can be used which reorders the output of the fft command such that the frequencies run from -pi/T, the negative Nyquist frequency, to pi/T, the Nyquist frequency. However, you then have to change the frequency vector for plotting on your own. For this exercise, we only need the frequencies from 0 to the Nyquist frequency, so only consider the plot in the range of 0 &#8804; &#969; &#8804; 30 rad/sec. (d). Recall that Y(&#969;) = X(&#969;)H(&#969;). Compute the approximation to H(&#969;) by dividing the elements of Y by the elements of X. Plot the frequency response |H(&#969;)|. What sort of filter does this represent? What is its bandwidth?

See Contifft program below.

Contfft Program

function [X,w] = contfft(x,T);
% CONTFFT [X,w] = contfft(x,T)
%
% Computes the Fourier transform of a continuous time signal
% using the FFT. The input is the sampled continuous
% time signal x and the sampling time T. The output is
% the Fourier transform X(w) and the frequency vector w.
%
[n,m] = size(x);
if n<m,
x = x';
end
Xn = fft(x);
N = length(x);
n = 0:N-1;
n(1) = eps;
X = (1-exp(-j*2*pi*n/N))./(j*2*pi*n/N/T).*Xn.';
w = 2*pi*n/N/T;

https://brainmass.com/engineering/electrical-engineering/fourier-analysis-of-system-in-matlab-151812

#### Solution Summary

The solution is comprised of detailed application of contfft function in Matlab.

\$2.19

## Matlab - A discrete-time system has the following unit-pulse response

There are two files which both need completed. Please see attached files for full problem description.
Please be sure to provide code and plots. Thanks.

Lab 2:
1. A discrete-time system has the following unit-pulse response:
h[n] = 0.5^n - 0.25^n, for n >= 0
Correspondingly, the following difference equation describes the behavior of the system:
y[n+2] - 0.75y[n+1] + 0.125y[n] = 0.25x[n+1]

A. Use the MATLAB command conv to calculate the response of the system to
a unit step input, x[n]=u[n]. Consider 0 =< n <= 20. Show what you type into
the MATLAB command window and submit a plot of the output. Please label the axes.

B Use the MATLAB script recur to calculate the response of the system to a
unit step input, x[n]=u[n]. Again consider 0 =< n <= 20. Show all that you type
into the MATLAB command window. Submit a plot of the output with the axes labeled.

Lab 3:
The continuous time function. This signal is a sinc function defined as y(t) = sinc(t). The Fourier transform of this signal is a
rectangle function.
1. Use the function linspace to create a vector of time values from -5 =<t <=5. Next, plot the function using the sinc function for y(t) = sinc(t).
2. Using MATLAB and the command fft, show that the Fourier transform pair is indeed a rectangle function. Use the command fftshift to center your plot.. Show both the m-file code and plot.
3. Using the same time values, plot the continuous time function defined as y(t) = sinc(2t).
4. Plot the transform pair for this signal.

Discussion:
1. What is the "ringing" caused from seen on top of the rectangular pulse?
2. In step 3 above, the sinc function gets compressed or smaller by a factor of 2. What happened to the rectangular pulse in the frequency domain? What property does this relate to?

View Full Posting Details