Lab 02A-Signals and Wave Form Generation: Objectives
Lab 02A-Signals and Wave Form Generation: Objectives
1. Objectives:
(a). To generate some simple and complex signals and visualize them
Source code:
x4=t4;
subplot(2,3,4);
plot(t4,x4);
xlabel('time');
ylabel('Amplitude');
title('Unit ramp signal');
%SINUSOIDAL SIGNAL
A=input('Enter the amplitude:');
f=input('Enter the frequency:');
t5=-10:1:20;
x5=A*sin(2*pi*f*t5);
subplot(2,3,5);
plot(t5,x5)
xlabel('time');
ylabel('Amplitude');
title('Sinusoidal signal');
%RANDOM SIGNAL
t6=-10:1:20;
x6=rand(1,31);
subplot(2,3,6);
plot(t6,x6);
xlabel('time');
ylabel('Amplitude');
title('Random signal');
stem(n2,x2);
xlabel('time');
ylabel('Amplitude');
title('Unit step signal');
%EXPONENTIAL SIGNAL
a=input('Enter the value of a:');
n3=-10:1:20;
x3=power(a,n3);
subplot(2,3,3);
stem(n3,x3);
xlabel('time');
ylabel('Amplitude');
title('Exponential signal');
%UNIT RAMP SIGNAL
n4=-10:1:20;
x4=n4;
subplot(2,3,4);
stem(n4,x4);
xlabel('time');
ylabel('Amplitude');
title('Unit ramp signal');
%SINUSOIDAL SIGNAL
A=input('Enter the amplitude:');
f=input('Enter the frequency:');
n5=-10:1:20;
x5=A*sin(2*pi*f*n5);
subplot(2,3,5);
stem(n5,x5);
xlabel('time');
ylabel('Amplitude');
title('Sinusoidal signal');
%RANDOM SIGNAL
n6=-10:1:20;
x6=rand(1,31);
subplot(2,3,6);
stem(n6,x6);
xlabel('time');
ylabel('Amplitude');
title('Random signal');
5|Page Digital Signal Processing
7. Results
Continuous time:
Discrete time:
c) Sinusoids--- the most general category of signals. Yes, it’s true. Believe it or not, every signal in this
universe contains nothing but sinusoids. We’ll explore this aspect in detail in our later labs, but for now,
these signals are quite interesting and beautiful to be looked in detail.
x1[n] = sin (
17
π
n), 0 ≤ n ≤ 25
x2[n] = cos (17πn), -15 ≤ n ≤ 15
x3[n] = sin (3 π n), -10 ≤ n ≤ 10
x4[n] = cos (23πn), 0 ≤ n ≤ 50
See the figures for each of the signals and comment about each with the aspect of even and odd, periodic
and aperiodic etc. Can you think of representing x3[n] without trigonometric functions?
We would be dealing with sinusoids quite frequently in future. It’s a good idea if we can understand the
mathematics of a sinusoidal signal and write a general function for it.
(i) Write a function to generate a sinusoid of given specifications: it should take six parameters: Freq,
Amplitude, Initial Phase, Sampling Freq., Start-Time, Stop Time.
(ii) Generate: s(t) = 50cos(2pi*1200*t + pi/4), using the above function.
If you are done with the simple practice session, Change the start and stop time in the above function to
generate a cosine which appears to be a sine.
(iii) Complex Exponentials: Generate x0[n] = exp(j*n/3), for some range and see its
real and imaginary parts separately. Also make the following signals:
• x1[n] = e(-0.1+j0.3)n, -10 ≤ n ≤ 10
• x2[n] = an u[n], where a=0.9, and 1.1 for -50 ≤ n ≤ 100
• x3[n] = 3 sin (17πn) + j 4 cos (17πn), 0 ≤ n ≤ 25
You may like to listen to these sinusoids, or some of these. Use MATLAB’s ‘sound’ to play your signal
at the sound card. What’s ‘fs’ in this sound? Explore ‘wavread’, ‘wavwrite’ also, and try to understand
the phenomenon involved. Play some sinusoids of audible frequency range. What happens if we use our
functions double, half, fliplr etc before playing the sinusoid?
8|Page Digital Signal Processing
Summary: This lab gives a tutorial about generating different continuous and discrete time signals
in MATLAB.
Instructions:
1. Do it yourself.
2. Attach Extra sheets for the problems which should include the code and its results screen shots.
3. Submit it before leaving until been specified by teacher
4. After marking, these will be deposited with teacher for record.