Signals and Systems Lab Manual: University of Engineering & Technology, Taxila
Signals and Systems Lab Manual: University of Engineering & Technology, Taxila
Lab Manual
Name: _________________________________________
Prepared by:
Checked by:
Date:
Software Requirements
Table of Contents
Experiment # 1
Equipment Matlab
Required:
For example
x=1:2:10
will generate x= 1 3 5 7 9
Try using angles=(0.01:0.01:1.00)*pi;
Transpose Operator(‘):
This operator swaps the rows and columns of any array that it is
applied to.
For example try using:
F=[1:4]
And F=[1:4]’
Initializing with Built-in functions:
Try using these:
A=zeros(2)
B=zeros(2,3)
C=[1 2; 3 4]
D=zeros(size(C))
E=ones(3)
Ones(3,1)
Eye(3)
Eye(3,2)
Length(C) //Generate the longest dimension of
the array.
Zeros can be used to create an all zero array of any desired size. If
function has a single square array; it will generate a square array
using the single argument as both the number of rows and columns.
size function returns two values containing the number of rows and
columns in an array.
Initializing variables with keyboard input:
Input function displays a prompt string in the command window and
then waits for the user to type in a response. For example , consider
the following statement:
My_val=input(‘enter an input value’);
Multidimensioanl Array
Matlab allows us to create arrays as many dimensions as necessary
for any given problem. These arrays have one subscript for each
dimension and an individual element in the array will be the product
of the maximum value of each subscript. For example the following
two statements create a 2X2X3 array C:
C(:,:,1)=[1 2 3; 4 5 6];
C(:,:,2)=[7 8 9; 10 11 12];
Whos C
SubArrays
It is possible to select and use subsets of arrays as though they
were separate arrays. To select a portion of array, just include a list
of all of the elements to be selected in the parenthesis after the rray
name. For example:
Arr1=[1.1 2.2 3.3 4.4 5.5]
Try using Arr1(3)
And Arr1([1 4])
And also Arr1(1:2:5)
End Function:
It is very useful for creating array subscripts. When used in an array
subscript; end returns the highest value taken on by that subscript.
For example. Suppose that array arr3 is defined as follows:
Arr3=[ 1 2 3 4 5 6 7 8];
Then Arr1(5:end) would be the array [5 6 7 8] and array(end) would
generate 8.
The value returned by end is always the highest value of a given
subscript. Is end appears in different subscripts, it can return
different values within the same expression. For example, suppose
that the 3X4 array Arr4 is defined as follows:
Arr4=[1 2 3 4; 5 6 7 8; 9 10 11 12];
Then the expression
Arr4(2:end, 2:end)
would return the array.(Try this one).
TASKS
Question # 01:
This M-file calculates and plot the function sin(x) for 0<=x<=6
X=0:0.1:6;
Y=sin(X);
plot(X,Y);
plot(X,Y)
Question # 02:
The following Matlab statement plot the function y(x)=2e-0.2x for the
range 0<=x<=10
X=0:0.1:10;
Y=2*exp(0.2*X);
Plot(X,Y);
Question # 03:
suppose that u=1 and v=3. Evaluate the following expressions using
Matlab.
(a) 4u/3v
(b)2v-2/(u+v)2
(c) v3/v3-u3
(d)4/3 pi.v2
Question # 04:
(a) Generate a 6X6 Matrix.
(b)Generate a 6X1 Matrix
(c) Generate a 3X4 Matrix
Question # 05
Answer the following questions for the array shown below.
1.1 0.0 2.1 -3.5 6.0
0.0 1.1 -6.6 2.8 3.4
1.1 0.1 0.3 -0.4 1.3
-1.4 5.1 0.0 1.1 0.0
Question # 08
Assume that the array is defined as follows; determine the contents
of the following subarrays
(a) array(3,:)
(b)array(:,3)
(c) array(1:2:3,[3 3 4])
(d)array([1 1],:)
Experiment # 2
Equipment Matlab
Required:
Question # 01:
Assume that value has been initialized to 10pi and determine what is
printed out by eah of the following statements:
(a) disp([‘value=’num2str(value)]);
(b)disp([‘value=’int2str(value)]);
(c) fprintf(‘value=%e\n’,value);
(d)fprintf(‘value=%f\n’,value);
(e) fprintf(‘value=%12.4f\n’,value);
Question # 02:
Evaluate the following expressions
(a) 11/5+6
(b) (11/5)+6
(c) 11/(5+6)
(d) 3^2^3
(e) (3^2)^3
(f) 3^(2^3)
(g) round(-11/5)+6
(h) ceil(-11/5)+6
(i) floor(-11/5)+6
Question # 03:
Evaluate the following Matlab expressions
(a) 5.5>=5
(b)20>20
(c) xor(17-pi<15,pi<3)
(d)true>false
(e) ~~(35/17)==(35/17)
(f) (17<=8)==(3/2==1)
(g)17.5&&(3.3>2.)
Question # 04:
The following statements are intended to alert a user to dangerously
high oral thermometer readings(values are in degree Farenheit ). Are
they correct or incorrect? If they are incorrect, why and correct them
if temp<97.5
disp(‘Temperature below normal’)
elseif temp>97.5
disp(‘temperature normal’)
elseif temp>99.5
disp(‘temperature slightly high)
elseif temp>103.0
disp(‘temperature dangerously high’)
end
Question # 05:
The cost of sending a packet by an express delivery service is $12.00
for the first two pounds and $4.50 for each pound or fraction thereof
over two pounds. If the package weighs more than 70 pounds, a $ 15.00
excess weight surcharge is added to cost. No package over 100 pounds
will be accepted. Write a program that accepts the weight of a package
in pounds and computes the cost of mailing the package. Be sure to
handle the case of overweight packages.
Question # 06:
Implement the following function f(x,y) as follows:
X+Y for X>=0 and Y>=0
X+Y2 for X>=0 and Y<0
X2 + Y for X<0 and Y>=0
X2+Y2 for X<0 and Y<0
Question # 07:
Try these built-in functions in Matlab
Abs(x)
Acos(x)
Asin(x)
Atan(x)
Atan2(y,x)
Ceil(x)
Fix(x)
Floor(x)
Round(x)
Char(x)
Experiment # 3
Equipment Matlab
Required:
Question # 01:
Implement unit impulse function in Matlab
Question # 02:
Implement Unit step function in matlab
Question # 03:
Classify signal as even or odd in Matlab
Experiment # 4
Equipment Matlab
Required:
Question # 01:
Calculate factorial of a number
Question # 02:
Implement the equation y(x)=x2-3x+2 for all the values of x between
-1 and 3 with the increment of 0.1.
Question # 03:
Take a signal and scale it.
Experiment # 5
Learning Implementing (1) Decibel (2) Taking input from the user
Objectives: (3) Root mean square (4) Harmonic mean (5) Selection
sort
Equipment Matlab
Required:
Question # 01:
Engineers often measure the ratio of two power measurements in
decibels or dB. The equation for the ratio of two power measurements
in decibel is
dB=10log10p2/p1
where p2 is the power level being measured and P1 is some reference
power level. Assume that the reference power level P1 is 1 Watt and
write a program that calculates the decibel level corresponding to
power levels between 1 and 20 watts in increment of 02 Watt steps.
Plot the dB-versus-power level on a log-linear scale.
Question # 02:
Write a matlab program that will accept an arbitrary number of
possible input values and calculate both the arithmetic mean and
geometric mean of the numbers. Use a While loop to get the input
values and terminate the inputs when the user inputs a negative value.
Question # 03:
Write a matlab program that will accept an arbitrary number of inputs
and caluculate the rms average of the numbers. Propmpt the user for
the number of values to be entered and use a FOR loop to read in the
numbers.
Question # 04:
Write a matlab program that will read an arbitrary number of possible
input values and caluculate the harmonic mean of the numbers. Use
any method you desire to read in the input values.
Question # 05:
Write a matlab program for the selection sort. The program should
accept 5 input values and sort them according to the criteria
Question # 06:
Modify the selection sort so that it accepts a second parameter which
may be “UP” or “DOWN” . if the input argement is UP, sort the values
in ascending order. If the argument is “DOWN” , sort the values in
descending order. If the argument is missing, the default case is to sort
the values in ascending order. (Be sure to handle the case of invalid
arguments, and be sure to include the proper help information in your
functon)
Experiment # 6
Equipment Matlab
Required:
Question # 01:
Look for the Matlab commands
fft
Ifft
Conv
Question # 02:
Generate a signal as sum of two sinusoidal of frequency f1=400Hz and
f2=800Hz.Use fft to find the Fourier transform.
Question # 03:
Calculate Fourier transform of e^-at u(t).Plot original signal, magnitude
and phase of its Fourier transform and verify it from text book
example#4.1
Question # 04:
Convolve the signals x1(t)=e^at and x2(t)=sint for 100 samples. Verify
that “convolution in time domain equals multiplication in frequency
domain.”
Question # 05:
Prove that FT of sinc is gate & ifft of gate is sinc.
Experiment # 7
Equipment Matlab
Required:
Question # 01:
Verify following fourier transform properties in matlab
Linearity: a . x[n] + b . y[n] a. X + b.Y
Shifting: x[n-nd] exp(-jwnd)X
Inverting: x[-n] X(exp(-jw))
Experiment # 8
Learning Convolution
Objectives:
Equipment Matlab
Required:
Question # 01:
Convolution of any two rectangular pulses
Experiment # 9
Equipment Matlab
Required:
Question # 01:
Make your own convolution code; perform convolution of two
rectangular pulses; show the step by step procedure (via flip and drag)
of convolution; compare your results with the built in Convolution
command.
Experiment # 10
Equipment Matlab
Required:
Question # 01:
Find the Z-transform of
(1) Impulse
(2) Unit step
(3) Delayed impulse by one unit to the right
(4) Delayed Unit step by one unit to the right
(5) anU(n)
(6) Sin wn
(7) Coswn
Question # 02:
Find the inverse Z-transform of all the answers collected from question
# 01 and verify the answer that what you got in question 1 was right
Question # 03:
Take any two vectors and find their roots
Question # 04:
Display the pole-zero plot of
A=[0 1 1]
B=[1 -2 3]
Question # 05:
Try to make your own matlab code for the Z-transform; (Bonus marks)
Experiment # 11
Equipment Matlab
Required:
Question # 01:
Create a signal x(t)=coswo(t). Generate the impulse train p(t) and
sample the signal using x(t)=x(t)p(t). Plot observed samples in Time
Domain.
Question # 02:
Now Plot spectra of x(t) & p(t) and convolve both spectras. Also obtain
spectra of sampled signal from question 1.
Question # 03:
Study Aliasing from question 2. Consider the following frequencies for
Sampling.
a)f0=fs/2 b)f0=3/2fs
Experiment # 12
Equipment Matlab
Required:
Question # 01:
With reference to the previous lab; Take any arbitrary signal; sample it;
Verify nyguist theorem.
Experiment # 13
Equipment Matlab
Required:
Question # 01:
The experiment implements a gui-based tutorial of the effect of
multiplying a cosine with a carrier frequency ‘fc’ with a given signal.
And the effect are monitored both in time and frequency domain.
The parameters that the gui would take:
‘fc’: the carrier frequency
‘fs’: the sampling frequency
Equipment Multimedia
Required:
Question # 01:
Experiment # 15
Equipment Multimedia
Required:
Question # 01:
Equipment Multimedia
Required:
Question # 01:
Implementing a moving average filter and plotting the magnitude and
phase of its Fourier transform.