Professional Documents
Culture Documents
Signals and Systems Expertment Instruction Material
Signals and Systems Expertment Instruction Material
Signals and Systems Expertment Instruction Material
Jiesi Luo
(1) Familiar with the commonly used MATLAB function for signals and systems simulation
(2) Learn to express the continuous-time signals and discrete-time signals with MATLAB, and
(3) Familiar with the principle and method for the basic transform and operation of signals in
time-domain, and realize the above principle and method in the MATLAB simulation
environment.
(5) Use the MATLAB convolution toolbox to perform the convolution operation.
(1) Unit step signal u(t) and unit impulse signal (t) are two very important signals in
(t )dt 1
t 1.1(a)
(t ) 0, t0
1, t 0
u (t ) 1.1(b)
0, t 0
The MATLAB extension function to generate the unit impulse signal and the unit step signal are
respectively given in the following;
% The MATLAB extension function to generate the unit impulse signal (t)
function y = delta(t)
dt = 0.01;
y = (u(t)-u(t-dt))/dt;
% The MATLAB extension function to generate the unit step signal u(t)
function y = u(t)
y = (t>=0); % y = 1 for t > 0, else y = 0
Please name the above two MATLAB extension function as delta and u in order, and store them in
Word for the later use.
(2) The discrete-time unit step signal are defined as:
1, n 0
u[n] 1.2
0, n 0
In addition to the above MATLAB extension function, the MATLAB inner function
ones(1,N) also can be used to generate the discrete-time unit step signal. It is worth noting that
ones(1,N) cant generate the true discrete-time unit step signal, and it only generate a unit gate
signal with N length, i.e., u[n]-u[n-N]. However, in a limited graphical window, what we can see
is a unit step series.
(3) Addition and multiplication operation for signals
The (transient) sum of signal f1 and f2 is the sum-signal f3=f1+f2 which consisted of the sum
value of signal f1 and f2 at the same instant. Similarly, the transient product signal of f1 and f2 is
the product-signal f3=f1*f2 which consisted of the product value of signal f1 and f2 at the same
instant. In other words, the addition (or multiplication) of the discrete series can be calculated by
adding (or) multiplying the corresponding value of the discrete series together.
When running the above programs, we must create the following sub-
function of u(t) in the programs execution path
function y = u(t)
y = (t>=0); % y = 1 for t > 0, else y = 0
Save the above function as u.m
(5) Time reversal of signals
Time reversal of signals can be described as the following mathematical expression;
Time shift of a continuous signal x(t) which denoted as y(t) can be expressed as
y[n] = x[-n] 1.4
Implement of the time reversal in MATLAB is very simple. Many approaches can be used to
accomplish time reversal operation.
Method 1, modifying the time variable t and n to t and n in the drawing function plot(t,x)
and stem(n,x). And the final figure will look like as the time reversal version of the original signal.
Method 2, directly implementing the time reversal of signals by the mathematics relationship
between the time reversal signal and the original signal. This method is the best-fit method in the
practical significant of signals time reversal operation.
Method 3 Using the MATLAB inner function fliplr() to implement the time
reversal of signal. Its usage is as follows
y = fliplr(x),where x is the original signalx(t) or x[n], and y is the time reversal of x. It is
important to note that function fliplr(x) reverses the order of each member of the signal x to
accomplish the time reversal, this reversal is independent with time variable t or n. Therefore, if it
exists a mathematics function can be used to express the signal x and its time variable, we suggest
to restrict the range of the time variable t or n in a positive and negative symmetry.
Write programs to implement m=sin(t), n=sin(-t), x[n]=[1,2,3,4], x[-n], and analysis the
waveform of the above signal.
The implementation program are as follows:
% Program 1-6
t=0:0.01:4*pi;
n=0:1:3;
m=sin(t);
x=[1 2 3 4];
subplot(222);
plot(t,m);
title('sin(t) signal');
subplot(221);
plot(-t,m);
title('sin(-t) signal');
subplot(224);
stem(n,x);
title('x[n] signal');
subplot(223);
stem(-n,x);
title('x[-n] signal');
The result is shown as Figure1.4;
When we process the time continuous signals in MATLAB, the step-size of independent variable t
should be very small. Suppose the time step-size is denoted as dt, when we use function conv() to
implemet the comvoltion intergral of two time continuous signals, we should multiply the function
conv() by time step-size in its front. That is to say that the correct sentences is y =
dt*conv(x,h).
Given two time continuous signals x (t) = t[u(t)-u(t-1)] and h(t) = u(t)-u(t-1)write MATLAB
programs to accomplish the convolution opertaion of these two signals, and plot their waveform in
time domian.
The implementation program are as follows:
% Program 1-9
t0 = -2; t1 = 4; dt = 0.01;
t = t0:dt:t1;
x = u(t)-u(t-1);
h = t.*(u(t)-u(t-1));
y = dt*conv(x,h); % Compute the convolution of x(t) and h(t)
subplot(221)
plot(t,x), grid on, title('Signal x(t)'), axis([t0,t1,-0.2,1.2])
subplot(222)
plot(t,h), grid on, title('Signal h(t)'), axis([t0,t1,-0.2,1.2])
subplot(212)
t = 2*t0:dt:2*t1; % Again specify the time range to be suitable to the
% convolution of x and h.
plot(t,y), grid on, title('The convolution of x(t) and h(t)'), axis([2*t0,2*t1,-0.1,0.6]),
xlabel('Time t sec')
The result is shown as Figure1.7;
Figure 1.7 the figure for the result of program 1-9
Sometimes,there are one or both two of the two signals for convolution computaion are very
long, even infinite. For processing these signas with MATLAB, they are always regards as finte
length signals, and the specific length is determined by the programmers. Although there exist
inevitable errors in the truncation of signals, these kind of errors can be reduced to an acceptable
level by the reasonable selection of the signal length. For example, given a signal x[n] = 0.5 nu[n],
and specify the range of n is 0 n 100, i.e., the length of x[n] is 101 points. Although the wider
the range of n, the more consistent wiht the practice of x[n]. However for x[n] = 0.5 nu[n],when
n=7, x[7] equals to 0.0078, this value is very small.Therefore, to specify a more longer range of n
for siganl x[n] is not necessay.
(9) Supplemental material for MATLAB used in signal processing.
When we plot the waveform of signals, we often need to show more than one figure in a
same graphical window. In MATLAB, function suboplot() is used to breaks the graphical window
into many sub-windows. For example, subplot(n1,n2,n3) breaks the current graphical window into
n1n2 sub-windows, and plot the figure in the n3th sub-window.
axis([xmin,xmax,ymin,ymax]) is a often used graphic control function, where xmin, xmax is
the starting point and ending point of the horizontal axis to show the waveform, and ymin and
ymax is the starting point and ending point of the horizontal axis to show the waveform.
Sometimes, to improve the readability of the figure, to add some grid lines to reflect the
amplitude of signals is necessary.
In MATLAB, grid on/grid off can be used to add/delete the requisite grid lines to your figure.
3. The experiment contents and steps
Prior to the experiment, all the students should read the above experiment principle for
experiment 1, and understand all the sample programs. To run all the sample programs in the
computer at the beginning of the experiment. And observe the plotted waveform for signals.
Exercise 1:Write a program to implement a unit gate signal with length of 4, and plot the
waveform in time domain.
Exercise 2: Write programs to plot the waveform of m=sin(t), g=sin(2t-pi/2),
x[n]=[1 2 5 6 3 ], x[(1/2)n-1], and analysis the tranfrom progress of the
waveform.
Exercise 3: Write programs to accomplish the convolution opertaion of these two signals
x[n]=[1 3 4 2 6 7], y[n]=[4,3,2,6,7,6,5].
Experiment 2 Fourier Series Representation of Periodic Signals and Gibbs
Phenomenon
1. Experiment Objectives
(1) Understand the physical interpretation of continuous time Fourier series(CTFS)
representation for periodic signals and master the analysis methods.
(2) Observe the Gibbs phenomenon resulted from the truncation of Fourier series
analysis, and understand its characteristics and reasons.
(3) Understand the physical interpretation of the continuous time Fourier transform
(CTFT) for periodic signals and master the analysis methods.
2. The principle of experiment
(1) The continuous time Fourier series (CTFS) representation
If the Dirichlet conditions are satisfied, a periodic signal with period T1 can be
represented as Fourier series.
With Fourier series, a periodic signal is represented as the linear combination of
complex exponential signals. The Fourier series representation of the periodic signal
x(t) is shown as formula (2.1)
x (t ) a
k
k e jk0t (2.1)
Where a k are the Fourier series coefficients, and it can be calculated with the
following formula
T1 / 2
1
x(t )e
jk0t
ak dt (2.2)
T1 T1 / 2
Fourier series with complex exponential form tell us that as long as the Dirichlet
conditions are satisfied, any periodic signal can be represented by a series of
harmonically related periodic complex exponential signals. Periodic complex
exponential signals with different frequencies are called as fundamental frequency
components, and a k are their complex amplitude, and a k are usually complex
numbers.
The formula(2.1) indicates that we can use infinite complex exponential signals
with different frequencies to form any one periodic signal. However, it is impossible
to use infinite complex exponential signals to form a periodic signal by computer or
any other equipment. A periodic signal only can be approximated by a linear
combination of a finite number of complex exponential signals. Suppose the finite
number is N, then the formula can be rewritten as
N
x(t ) a k e jk0t
k N (2.3)
Obviously, the bigger of N, the more close of the synthesis result to the original
signal x(t). This experiment can help readers to understand the
the physical interpretation of (CTFS), and to observe the influences of the different frequency
components of the Fourier series to the waveform. Gibbs phenomenon, i.e., for the waveform of
the synthesis signal, there exists an overshoot of 9% of the height near the discontinuity point of
the original signal, and the bigger of N, the nearer of the overshoot point to the discontinuity. This
phenomenon can be seen clearly by the observation of the rectangular wave signal and the
sawtooth wave signal.
Example one, a periodic rectangular signal is shown in Fig.2.1, and its mathematic
expression is as follows:
1, 0 t 1
x1 (t)
0, 1 t 2
x1 (t )e 0 dt
jk t
ak
2 0 e
jk 0 t
e jk 0 t dt d ( jk0t )
T1 T1 / 2
j 2k0 0
k k k
e jk 0 t
e jk 0 1
1
k
j e
j
2
e
j
2 sin( 0 ) j k 0
0 0
0
2
j 2k0 e
0
j 2k0
2
e 2
j 2k0 k0
k
sin( )
For 0 = 2/T1 = then a ( j ) k 2
k
k
Type the following program in MATLB command:
>> k = -10:10;
>> ak = ((-j).^k).* (sin((k+eps)*pi/2)./((k+eps)*pi)) % The expression
of ak
ak =
Columns 1 through 4
-0.0000 0 + 0.0354i -0.0000 0 + 0.0455i
Columns 5 through 8
-0.0000 0 + 0.0637i -0.0000 0 + 0.1061i
Columns 9 through 12
-0.0000 0 + 0.3183i 0.5000 0 - 0.3183i
Columns 13 through 16
-0.0000 0 - 0.1061i -0.0000 0 - 0.0637i
Columns 17 through 20
-0.0000 0 - 0.0455i -0.0000
0 - 0.0354i
Column 21
-0.0000
From the MATLAB command window, we can
get the Fourier series coefficients from a 10 a10 .
Then type the following program:
>> subplot(221)
>> stem(k,abs(ak),'k.')
>> title('The Fourier series
coefficients') Figure 2.2 The Fourier series coefficients
>> xlabel('Frequency index k')
Figure 2.2 can be obtained, and Figure 2.2 shows the relationship between a k and k
The above Fourier series coefficients and its frequency spectrum are calculated by hand. The
MALAB example to complete the calculation of Fourier series coefficient is given as program2_1
% Program2_1
% This program is used to evaluate the Fourier series coefficients ak of a periodic square wave
clear, close all
T = 2; dt = 0.00001; t = -2:dt:2;
x1 = u(t) - u(t-1-dt); x = 0;
for m = -1:1 % Periodically extend x1(t) to form a periodic signal
x = x + u(t-m*T) - u(t-1-m*T-dt);
end
w0 = 2*pi/T;
N = 10; % The number of the harmonic components
L = 2*N+1;
for k = -N: N; % Evaluate the Fourier series coefficients ak
ak(N+1+k) = (1/T)*x1*exp(-j*k*w0*t')*dt;
end
phi = angle(ak); % Evaluate the phase of ak
Running the program2_1, and type ak in command window, then the 21 coefficients will be
displayed :
ak =
Columns 1 through 4
0.0000 + 0.0000i 0.0000 + 0.0354i 0.0000 - 0.0000i 0.0000 +
0.0455i
Columns 5 through 8
0.0000 - 0.0000i 0.0000 + 0.0637i 0.0000 - 0.0000i 0.0000 +
0.1061i
Columns 9 through 12
0.0000 - 0.0000i 0.0000 + 0.3183i 0.5000 0.0000 - 0.3183i
Columns 13 through 16
0.0000 + 0.0000i 0.0000 - 0.1061i 0.0000 + 0.0000i 0.0000 -
0.0637i
Columns 17 through 20
0.0000 + 0.0000i 0.0000 - 0.0455i 0.0000 + 0.0000i 0.0000 -
0.0354i
Column 21
0.0000 - 0.0000i
We can see that ak obtained from program2_1 and ak from the previous hand calculation have
the same value.
Note: In program2_1, the value of dt can affect the calculation accuracy of the Fourier
coefficient. The smaller value of dt, the higher precision we get. So in Program2_1, the value of dt
is 0.00001. However, the higher precision we get, the more longer of compute time.
k N
where r is the number of loops. The MATLAB programs are given as follows:
x2 = 0; L = 2*N+1;
for r = 1:L;
x2 = x2+ak(r)*exp(j*(r-1-N)*w0*t);
end;
The periodic rectangular signal shown in Figure 2.1 is the best example to observe
the Gibbs phenomenon. This periodic rectangular signal have two discontinuous
points in one period, use the limited items to synthesis this signal will arouse the
Gibbs phenomenon, and it is obvious to be observed.
Example two: revise the program2_1, use the limited items of complex exponential
signals to synthesis the periodic rectangular signal exhibited in Figure2.1, and plot the
waveform of the original signal and the synthesis signal, and the amplitude spectrum
and angle spectrum.
Program2_1 are revised as program2_2:
% Program2_2
% This program is used to compute the Fourier series coefficients ak of a periodic
square wave
clear,close all
T = 2; dt = 0.00001; t = -2:dt:2;
x1 = u(t)-u(t-1-dt); x = 0;
for m = -1:1
x = x + u(t-m*T) - u(t-1-m*T-dt); % Periodically extend x1(t) to form a
periodic signal
end
w0 = 2*pi/T;
N = input('Type in the number of the harmonic components N = :');
L = 2*N+1;
for k = -N:1:N;
ak(N+1+k) = (1/T)*x1*exp(-j*k*w0*t')*dt;
end
phi = angle(ak);
y=0;
for q = 1:L; % Synthesiz the periodic signal y(t) from the finite Fourier series
y = y+ak(q)*exp(j*(-(L-1)/2+q-1)*2*pi*t/T);
end;
subplot(221),
plot(t,x), title('The original signal x(t)'), axis([-2,2,-0.2,1.2]),
subplot(223),
plot(t,y), title('The synthesis signal y(t)'), axis([-2,2,-0.2,1.2]), xlabel('Time t'),
subplot(222)
k=-N:N; stem(k,abs(ak),'k.'), title('The amplitude |ak| of x(t)'), axis([-N,N,-
0.1,0.6])
subplot(224)
stem(k,phi,'r.'), title('The phase phi(k) of x(t)'), axis([-N,N,-2,2]), xlabel('Index
k')
Obviously, the sampled signal x s (t ) is also a impulse train, merely this impulse
train are weighed by x(nTs).
Since the frequency spectrum of signal p(t) also a impulse train, and
F { p (t )} s ( n s ) (3.4)
1
According to the frequency convolution theorem, X s ( j )
Ts
X ( j ( n
n
s ))
.
Therefore, the frequency spectrum of the sampled signal is the periodic extension of
the frequency spectrum of the original signal with the sampling frequency of s,
which can be seen in Figure3.2.
x(t ) X ( j )
t
M M
p(t ) P ( j )
s
t
Ts s s
xs (t ) 1 / Ts X s ( j )
t
3-2
Fig3.3 the waveform of the signal x(t) and its sampled signal xn
(2) The frequency alias in the sampling process
To observe whether the frequency alias are existed, or not, it is necessary to calculate
the Fourier transform of the sampled signal, and plot its frequency spectrum.
The following program3_2 is to calculate the Fourier transform of the sampled signal,
and plot its frequency spectrum.
% Program3_2
clear, close all,
tmax = 4; dt = 0.01;
t = 0:dt:tmax;
Ts = 1/10;
ws = 2*pi/Ts;
w0 = 20*pi; dw = 0.1;
w = -w0:dw:w0;
n = 0:1:tmax/Ts;
x = exp(-4*t).*u(t);
xn = exp(-4*n*Ts);
subplot(221)
plot(t,x), title('A continuous-time signal x(t)'),
xlabel('Time t'), axis([0,tmax,0,1]), grid on
subplot(223)
stem(n,xn,'.'), title('The sampled version x[n] of x(t)'),
xlabel('Time index n'), axis([0,tmax/Ts,0,1]), grid on
Xa = x*exp(-j*t'*w)*dt;
X = 0;
for k = -8:8;
X = X + x*exp(-j*t'*(w-k*ws))*dt;
end
subplot(222)
plot(w,abs(Xa))
title('Magnitude spectrum of x(t)'), grid on
axis([-60,60,0,1.8*max(abs(Xa))])
subplot(224)
plot(w,abs(X))
title('Magnitude spectrum of x[n]'), xlabel('Frequency in radians/s'),grid on
axis([-60,60,0,1.8*max(abs(Xa))])
x(t ) x p (t )
Ideal
Lowpass xr (t )
Filter
p (t )
Fig3.5
Where ideal lowpass filter is also called as reconstruction filter, and its impulse response is
c T sin( c t )
h(t ) (3.5)
c t
According to the convolution theorem, x r (t ) x p (t ) h(t ) , and for the mathematics formula of
the sampled signal is x p (t ) x(nT ) (t nT ) ,then
c T sin( c (t nT ))
x r (t ) x(nT )
n c (t nT )
(3.6)
The formula(3.6) is called as interpolation formula, it is based on that the reconstruction filter is
an ideal lowpass filter. Otherwise, the interpolation formula cant be used for the reconstruction of
signals.
Fig3.6 shows the idea lowpass filter and its impulse response.
H ( j ) h(t )
c
T T
t
c c
Fig3.6
The following program3_3 is the example program to complete the reconstruction of Signals:
% Program
% Signal sampling and reconstruction
% The original signal is the raised cosin signal: x(t) =
[1+cos(pi*t)].*[u(t+1)-u(t-1)].
clear; close all,
wm = 2*pi; % The highest frequency of x(t)
a = input('Type in the frequency rate ws/wm=:'); % ws is the
sampling frequency
wc = wm; % The cutoff frequency of the ideal lowpass
filter
t0 = 2; t = -t0:0.01:t0;
x = (1+cos(pi*t)).*(u(t+1)-u(t-1));
subplot(221); % Plot the original signal x(t)
plot(t,x); grid on, axis([-2,2,-0.5,2.5]);
title('Original signal x(t)');xlabel('Time t');
ws = a*wm; % Sampling frequency
Ts = 2*pi/ws; % Sampling period
N = fix(t0/Ts); % Determine the number of samplers
n = -N:N;
nTs = n*Ts; % The discrete time variable
xs = (1+cos(pi*nTs)).*(u(nTs+1)-u(nTs-1)); % The sampled version
of x(t)
subplot(2,2,2) % Plot xs
stem(n,xs,'.'); xlabel('Time index n'); grid on, title('Sampled version
x[n]');
xr = zeros(1,length(t)); % Specify a memory to save the
reconstructed signal
L = length(-N:N);
xa = xr;
figure(2); % Open a new figure window to see the demo of signal
reconstruction
stem(nTs,xs,'.'); xlabel('Time index n'); grid on;hold on
for i = 1:L
m = (L-1)/2+1-i;
xa = Ts*(wc)*xs(i)*sinc((wc)*(t+m*Ts)/pi)/pi;
plot(t,xa,'b:');axis([-2,2,-0.5,2.5]); hold on
pause
xr = xr+xa; % Interpolation
end
plot(t,xr,'r'); axis([-2,2,-0.5,2.5]); hold on
figure(1);
subplot(223)
plot(t,xr,'r');axis([-2,2,-0.5,2.5]);
xlabel('Time t');grid on
title('Reconstructed signal xr(t)');
% Compute the error between the reconstructed signal and the
original signal
error = abs(xr-x);
subplot(2,2,4)
plot(t,error);grid on
title('Error');xlabel('Time t')
Fig3.8
Note: according to the sampling theorem, ws/wm should be greater than or equal
to 2.
(1) Master the signal analysis methods in time domain and frequency domain.
i.e, the frequency domain analysis and time domain analysis. Fig4.1 is a simplified graphic for a
x (t ) y (t )
h(t )
LTIsystem
X ( j ) H ( j ) Y ( j )
In Fig3.4, x(t) and y(t) are respectively the time domain excitation signal and response signal of
the LTI system. h(t) is the unit impulse response of the LTI system. The relationship between there
three is y (t ) x (t ) * h(t ) . Based on the convolution theorem in time domain of the Fourier
transform, there exists the following equation:
Y ( j ) X ( j ) H ( j ) (4.1)
Y ( j )
or H ( j ) (4.2)
X ( j )
H ( j ) is the frequency response of the LTI system, in effect, it just is the Fourier transform of
j t
h(t),i.e., H ( j ) h (t ) e dt . As long as the unit impulse response h(t) is absolutely
H ( j ) H ( j ) e j ( ) (4.3)
Where H ( j ) is called as magnitude response, and it reflects the amplitude changes of the
signal components with different frequencies when a signal pass through the system. And ( )
is called as phase response, it reflects the phase changes of the signal components with different
frequencies when a signal pass through the system. Both H ( j ) and ( ) are the functions
of .
For a system, its frequency response is H(j), and the magnitude response and phase response
are H ( j ) and ( ) ,respectively. Suppose the input excitation signal x(t ) e j0t , then
y (t ) H ( j 0 )e j0t H ( j 0 ) e H ( j 0 ) e j (0t (0 ))
j ( 0 ) j 0 t
e
(4.4)
If the input excitation signal x(t) = sin(0t)then the response signal is
y (t ) H ( j 0 ) sin( 0 t ) | H ( j 0 ) | sin( 0 t ( 0 ))
(4.5)
Therefore, the influences of a system on a certain frequency component are reflected as two sides.
One side is the amplitude will be weighed by H ( j ) , another side is phase will be shifted by
( ) .
(3) Two examples will be introduced to illustrate the two analysis methods of signals when they
pass through a certain system.
Example 1. Write the MATLAB programs to complete a signal 6*sin(20*pi*t) pass through a
system, and the system is to multiply the signal 6*sin(20*pi*t) with signal sin(2*pi*t). plot the
waveform of the original signal and the response signal, and analyze the differences between these
two signals.
%program 4_1
t=0:0.01:2*pi;
m=6*sin(20*pi*t);
g=sin(2*pi*t);
y=m.*g;
subplot(311)
plot(t,m);
title('6*sin(20*pi*t) signal');
subplot(312)
plot(t,g);
title(' sin(2*pi*t) signal');
subplot(313);
plot(t,y);
title('The waveform of the response signal')
Example 2. Generate three sinusoidal signals, and its respective frequencies are 5Hz,15Hz, and
30Hz. And then design a filter system to filter the signals with the frequencies of 5Hz and 30Hz,
and retain the frequency of 15Hz. The programs are in the following.
%Program4_2
%generate a signal that contains three sinusoidal components
Fs=100;
t=(1:100)/Fs;
s1=sin(2*pi*t*5);
s2=sin(2*pi*t*15);
s3=sin(2*pi*t*30);
s=s1+s2+s3;
subplot(221);
plot(t,s);
xlabel('Time(second)');
ylabel('Time waveform');
title('The original signal ');
%generate a IIR filter with 8 orderthe pass frequecies are from 10Hz to 20, and the frequency
response are as follows:
[b,a]=ellip(4,0.1,40,[10 20]*2/Fs);
[H,w]=freqz(b,a,512);
subplot(222);
plot(w*Fs/(2*pi),abs(H));
title('the designed band pass filter ');
xlabel('Frequency(Hz)');ylabel('Mag.of frequency response');
grid on;
%to filter the original signal
sf=filter(b,a,s);
subplot(223);
plot(t,sf);
xlabel('Time(seconds)');
ylabel('Rime waveform');
title('the waveform of the filtered signal')
axis([0 1 -1 1]);
%plot the frequency spectrums of the original and filtered signal
S=fft(s,512);
SF=fft(sf,512);
w=(0:255)/256*(Fs/2);
subplot(224);
plot(w,abs(S(1:256)),'r--',w,abs(SF(1:256)),'g');
xlabel('Frequency(Hz)');ylabel('Mag.of Fourier transform');
title('the waveform of the original signal and the filered signal in frequency domian ')
grid on;legend('before','after')
3.The experiment contents and steps
Exercise 1. Please give the result figure of program 4_2.
Exercise 2. Write MALTAB program to simulate the following five signals:
u(t)=cos(2*pi*t); v(t)=4*cos(20*pi*t); y(t)=4*(1+2*cos(2*pi*t))*cos(20*pi*t);
y(t)=4*(1+0.5*cos(2*pi*t))*cos(20*pi*t) y(t)=4*(1+cos(2*pi*t))*cos(20*pi*t);
Analysis all the five signals in time domain and frequency domain,and plot the result figure. .