Professional Documents
Culture Documents
OF ENGINEERING
THEORY:
If the amplitude of the signal is defined at every instant of time then it is called continuous time signal. If the
amplitude of the signal is defined at only at some instants of time then it is called discrete time signal. If the
signal repeats itself at regular intervals then it is called periodic signal. Otherwise they are called aperiodic
signals.
Ramp signal: The ramp function is a unitary real function, easily computable as the mean of the independent
variable and its absolute value.This function is applied in engineering. The name ramp function is derived from
the appearance of its graph.
Unit step signal: The unit step function and the impulse function are considered to be fundamental functions in
engineering, and it is strongly recommended that the reader becomes very familiar with both of these functions.
=0 if t < 0
u(t) = 1 if t > 0
=1/2 If t=0
Sinc signal: There is a particular form that appears so frequently in communications engineering, that we
give it its own name. This function is called the "Sinc function”.
PROCEDURE:
PROGRAM:
Fs = 20; // samples per second t_total= 100; // seconds n_samples= Fs * t_total; t = linspace(0, t_total,
n_samples); f=40; // sound frequency
tri_wave=(2/%pi)*asin(sin(2*%pi*f*t)); plot(t,tri_wave);
xlabel(' ----------- >Time Index t (sec.)'); ylabel(' ------------ >Amplitude');
title ('Triangular Wave Signal Sequence');
// traiangular wave sequence Fs = 20; // samples per second t_total= 10; // seconds n_samples= Fs * t_total;
t = linspace(0, t_total, n_samples); f=40; // sound frequency
tri_wave=(2/%pi)*asin(sin(2*%pi*f*t)); plot(t,tri_wave); xlabel(' ----------- >Time Index t (sec.)'); ylabel('
------------ >Amplitude');
title ('Triangular Wave Signal Sequence');
// Sawtooth Wave Signal Fs = 20; // samples per second t_total= 10; // seconds n_samples= Fs * t_total; t =
linspace(0, t_total, n_samples); f=500; // sound frequency// Sawtooth wave
saw_wave=2*(f*tfloor(0.5+f*t)); plot(t,saw_wave); xlabel(" ----------- >Time Index t (sec.)"); ylabel("
------------ >Amplitude"); title ("Sawtooth Wave Signal Sequence");
// sawtooth wave sequenceFs = 20; // samples per second
// Unit Step Signal and Sequence: // Discrete Signal t=0:4; y=ones(1,5); subplot(2,1,1); plot2d3 (t,y);
xlabel('time'); ylabel('amplitude');
CONCLUSION: -
Hence various signals & sequences are generated using MATLAB software
EXPAREMENT 2
EQUIPMENTS:
PC with window
MATLAB Software
t = 0:1/50:10-1/50;
x = sin(2*pi*15*t) + sin(2*pi*20*t);
plot(t,x)
y = fft(x);
f = (0:length(y)-1)*50/length(y);
plot(f,abs(y))
title('Magnitude')
n = length(x);
fshift = (-n/2:n/2-1)*(50/n);
yshift = fftshift(y);
plot(fshift,abs(yshift))
ynoise = fft(xnoise);
ynoiseshift = fftshift(ynoise);
power = abs(ynoiseshift).^2/n;
plot(fshift,power)
title('Phase')
CONCLUSION: -
EXPERIMENT 3
Write a program to find response of a low pass filter and high pass filter
Purpose
The purpose of this lab is to introduce you to Low Pass and High Pass Filters. As part of performing
this lab you will
• Determine the amplitude and frequency response characteristics of Low and
High
Pass filters,
• Compare passive and active LPF and HPF filter configurations, and
•Compare theoretical models with actual filters.
THEORY
In this experiment you will design, build 1, and test four filters. The configurations you will build are
• Passive Low-Pass Filter,
• Active Low-Pass Filter, •Passive High-Pass Filter,
and •Active High-Pass Filter. For each of the
configurations you will
1. Design the filter for a specified cut-off frequency,
2. Model the filter in MatLab,
3. Simulate the design with PSpice2, and
4. Test the design in the Lab.
Steps 1, 2, and 3 are Prelab activities. Step 4 will be performed during the lab period.
In your report you will compare the theoretical and actual amplitude and phase plots for each of the
four configurations.
If you are rusty on transfer functions or op amp usage you may want to review those subjects.
1. Draw graphs showing the frequency responses of an ideal low-pass filter (LPF) and an
ideal high-pass (HPF) filter.
2. Generate a signal in MatLab composed of two sine waves using the following
parameters:
a) f1= 2000 Hz
b) f2= 40000 Hz
c) 0 t 2 milliseconds
d) Ts = 5 microseconds
e) y(t) = sin ( 2 f1 t ) + 0.25 cos ( 2 f2 t )
3. Plot the time domain and the frequency domain representations of the signal.
4. "Filter" the wave form by "zeroing out" the high frequency components of the FFT
wave form:
There are two ways in MatLab to "filter" a wave form. One technique is to "zero out" the higher
frequency elements of the FFT. The other is to use the transfer function of a low pass
filter. In the steps below you will zero out the high frequency elements of the FFT. a)%
create a new vector containing only the low
b) % frequency components of Y
c) L = length(Y);
d) NewY = zeros(L,1);
e) % define the number of data points to copy from the original file
f) NewY(1:b)=Y(1:b);
As an option, instead of replacing the values of higher frequency region with zeros, it is also feasible
to replace the original values with very small values, such as 0.001, which represent out of
band noise.
Although at this point you are not actually filtering the signal, you are performing the same kind of
function that a Low Pass Filter performs. The performance of this filtering method depends
on the number of vector elements you replace with zeros in the high frequency components
of the FFT.
5. After filtering in the frequency domain, reconstruct the signal using "ifft".
In your report, compare the reconstructed signal with the original signal in the time domain.
6. Repeat this procedure for the lower frequency region of the FFT and observe the output.
This method introduces the concept of filtering. This filtering is considered ideal filtering in terms
of the performance of the filtering. However this filtering requires additional procedure for
reconstruction of the signal. In the ‘real world’ the goal is to design filters that perform as
well as this simulation.
7. Use Convolution to demonstrate filtering. (This will use the convolution technique you
used in Lab 2.)
a) Determine the impulse response of the filter.
b) Convolve the impulse response of the filter with the signal that you are going to
filter.
Pre3_13.m simulates LPF filtering using this filtering method in MatLab. In your Lab Report,
comment on the performance of the filter.
1. Build the following passive high-pass filter in MicroSim and determine its transfer function
and cut-off frequency:
Figure 2. RC High Pass Filter
2. Build the following active low-pass filter in MicroSim and determine its transfer function
and cut-off frequency:
3. Build the following active high-pass filter in MicroSim and determine its transfer function
and cut-off frequency:
Figure 4. Sallen-Key Equal Component Active High Pass Filter
Lab Period – Low Pass and High Pass Filters
Function
Generator 1
2. Using WAVEFFT.VI, obtain the frequency spectrum of the input signal. Enter ts= 8E-3 as
the time span in the control panel of the VI. Measure the amplitude of the main peaks of the
spectrum.
Amplitude at f1(pi1) =
Amplitude at f2(pi2) =
3. Apply the signal to the circuit by connecting the leads as shown in Figure 5. Move the
channel 1 probe to the output of the RC Low Pass Filter. Run WAVEFFT.VI using the
same time span, remember to save the data with a different filename. Measure the amplitude
of the main peaks in the displayed spectrum.
Amplitude at f1(po1) =
Amplitude at f2(po2) =
4. What is the relationship between m1, pi1and po1? Verify your conclusion with m2, pi2 and
po2.
PROGRAMS:-
1. Construct the active Low Pass Filter shown in Figure 3 using the following
parameters:. Equipment Settings:
VCC 18 V (power supply voltages)
VSS -18 V
f13,000 Hz
f230,000 Hz
Amplitude 5 Vpp
LabVIEW Settings:
Lowfreq 100 Hz Upperfreq 30 kHz
points/decade 10
ts20E-3
2. Analyze the response of the filter by following the steps of Lab 3.1.
EXPERIMENT 4
AIM: Write a program to perform the operations on signals and sequences such as addition, multiplication,
scaling, shifting, folding and also compute energy and power.
THEORY:
Signal Addition
Multiplication:
Multiplication of two signals can be obtained by multiplying their values at every instants . z
z(t) = x (t) y (t)
Time reversal/Folding:
Time reversal of a signal x(t) can be obtained by folding the signal about t=0.
Y(t)=y(-t)
Signal Amplification/Scaling : Y(n)=ax(n) if a < 1 attnuation
a >1 amplification
Time shifting: The time shifting of x(n) obtained by delay or advance the signal in time by
using y(n)=x(n+k)
If k is a positive number, y(n) shifted to the right i e the shifting delays the signal
If k is a negative number, y(n ) it gets shifted left. Signal Shifting advances the signal
Energy:
Average power:
PROCEDURE:
1.Click on MATLAB Icon
PROGRAM:
// Addition
x=input('Enter the sequence 1=');
y=input('Enter the sequence 2=');
m=length(x); n=length(y); if m>n
y=[y,zeros(1,m-n)];
else
x=[x,zeros(1,n-m)];
end z=x+y;
disp(z,'Addition result of two unequal length sequences:=');
// Multiplication
x=input('Enter the sequence 1=');
y=input('Enter the sequence 2=');
m=length(x); n=length(y); if m>n
y=[y,zeros(1,m-n)]; else
x=[x,zeros(1,n-m)];
end z = x.*y;
disp(z, ' Multiplication result of two unequal lengths equences:= ' );
// Folding Operation
x = input( ' Enter the input sequence e := ' ); m = length (x);
s = input( ' Enter the starting point of original signal=' ); h
= s + m -1; n = s :1: h; subplot(2 ,1
,1)x_location= " o r i g i n "; y_location= "
o r i g i n "; data_bounds= [ -5 ,0;5 ,5];
plot2d3 (n,x)xlabel( ' n===>' ) ylabel( '
Amplitude' )title( ' Original Sequence ' )
subplot(2 ,1 ,2)x_location= " o r i g i n ";
y_location= " o r i g i n "; data_bounds= [
-5 ,0;5 ,5]; plot2d3 (-n,x)xlabel( ' n===>' )
ylabel( ' Amplitude' )title( ' Folded
Sequence ' )
// Scaling Operation
x = input( ' Ent e r input Sequence := ' );
m = length(x);
s= input( ' Enter starting point of originalsignal:= ' ) h
= s+m-1;
n = s :1: h;
C = input( 'Ent e r Compression factor Time Scaling factor' )
// shifting operation
disp(Energy);
subplot(3,2,3); plot2d3(n1,y3);
xlabel('time'); ylabel('amplitude');
title('scaling of Signals');
subplot(3,2,4); plot2d3(n1,y4);
xlabel('time'); ylabel('amplitude');
title('Folded Signal');
subplot(3,2,5); plot2d3(n1,y5);
xlabel('time'); ylabel('amplitude');
title('Addition of Signals');
subplot(3,2,6); plot2d3(n1,y6);
xlabel('time');
ylabel('amplitude');
title('Multiplication of Signals');
OUTPUT:
Enter the sequence 1=[1 2 3]
Enter the sequence 2=[2 3 4 5]
EXPERIMENT -5
AIM: Generation of Gaussian distribution length 1000random sequence .compute the mean and
variance of the random signal by a suitable method.
THEORY:
Gaussian noise is statistical noise that has a probability density function (abbreviated pdf) of the
normal distribution (also known as Gaussian distribution). In other words, the values the noise can take on are
Gaussian-distributed. It is most commonly used as additive white noise to yield additive white Gaussian noise
(AWGN).Gaussian noise is properly defined as the noise with a Gaussian amplitude distribution. says nothing
of the correlation of the noise in time or of the spectral density of the noise. Labeling Gaussian noise as 'white'
describes the correlation of the noise. It is necessary to use the term "white Gaussian noise" to be correct.
Gaussian noise is sometimes misunderstood to be white Gaussian noise, but this is not the case.
PROCEDURE:
1. Click on MATLAB Icon
2. Type the program on editor window
3. Save the program
4. Execute the program and observe the output/wave forms
.PROGRAM:
clc;
clear all;
close all;
N= input(' Enter the number of samples........ :: ');
R1=randn(1,N);
M=mean(R1);
K=kurtosis (R1);
P=periodgram(R1);
V=var(R1);
x = psd(R1);
subplot(2,2,1); plot(R1);
xlabel('Sample
Number');
ylabel('Amplitude');
title('Normal [Gaussian] Distributed Random Signal');
subplot(2,2,2);
hist(R1);
xlabel('Sample Number');
ylabel('Total');
title('Histogram [Pdf] of a normal Random Signal');
subplot(2,2,[3,4]);
plot(x);
xlabel('Sample Number'); ylabel('Amplitude');
title('PSD of a normal Random Signal');
OUTPUT:
CONCLUSION: -
EXPERIMENT NO- 06
THEORY:
The formula that gives the response y(n) of the LTI system as a function of the input signal x(n) and
the unit sample (impulse) response h(n) is called a convolution sum.We say that the input x(n) is
convoluted with the impulse response h(n) to yield the output y(n).
Convolution between x(n) and h(n) is represented as y(n)=x(n)*h(n),where ‘*’ denotes convolution
operation.
Mathematically convolution is represented as
∞
y(n)= ∑ x(k)h(n-k)
k=-∞
i) Commutative law-
x(n)*h(n)=h(n)*x(n)
ii)Associative law-
[ x(n)*h1(n)]*h2(n)= x(n)*[h1(n)*h2(n)]
iii)Distributive law-
x(n)*[h1(n)+h2(n)]= x(n)*h1(n)+x(n)*h2(n)
PROGRAM: -
clc
clear all
x=input('enter the 1st seq')
h=input('enter the second seq')
m=length(x)
p=length(h)
n=m+p-1
x=[x,zeros(1,p-1)]
z=zeros(1,p)
for i=1:n
for j=p:-1:2
z(j)=z(j-1)
end
z(1)=x(i)
sum=0
for k=1:p;
sum=sum+z(k)*h(k)
end
y(i)=sum
end
disp('the result is');y
subplot(3,1,1)
stem(x)
xlabel('time')
ylabel('amp')
title('x(n)')
subplot(3,1,2)
stem(h)
xlabel('time')
ylabel('amp')
title('h(n)')
subplot(3,1,3)
stem(y)
title('y(n)')
PLOTS FOR LINEAR CONVOLUTION
CONCLUSION: -
We got the result of linear convolution of two sequences and printed the output
EXPERIMENT NO- 07
OBJECTIVES:-
i) To generate two sequences x1 & x2 containing a number of samples.
ii) To find circular convolution between x1 &x2 using function file and script file.
iii) To find linear convolution between the same two sequences.
iv) To plot both linear and circular convolution.
THEORY
Linear Convolution-
i) If x(n) has ‘l’ samples and h(n) has’m’samples then y(n) result has ‘m+l-1’ number of
samples.
ii) There is no modulo-N operation.
iii) It is used to find the response of a filter.
Circular convolution-
i) Here output y(n) has max(l,m) number of samples .
ii) Shifting operation is done here in circular manner by computing index of one
iii) sequense modulo N.
iv) It cann’t be used to find response of a filter without zero padding.
PROGRAM
% FUNCTION FILE
function y=my_circonv(x1,x2)%function file declaration
%This gives circular convolution of x1,x2
%To call this:-y=my_circonv(x1,x2)
%The file is stored under the function name(my_circonv)
%y=output,x1=input,x2=input
n1=length(x1)
n2=length(x2)
n=max(n1,n2)
n3=n1-n2
if n3>0
x2=[x2,zeros(1,n3)]
else
x1=[x1,zeros(1,-n3)]
end
for a=1:n
y(a)=0
for i=1:n
j=a-i+1
if(j<=0)
j=n+j
end
y(a)=y(a)+(x1(i)*x2(j))
end
end
disp('result is');y
%SCRIPT FILE
%Comparision between circular & linear convolution
%This is a script file
CONCLUSION: -
We got the result of linear convolution of two sequences and circular convolution of two sequences
and printed the both.
EXPERIMENT NO- 08
n=-∞
or equivalently as as
n=∞
n=-∞
The index l is the (time) shift(or lag) parameter and subscripts xy in the cross correlation sequence
rxy(l) indicate the sequences being correlated.The order of subscripts with x proceeding y,indicates the
direction in which one sequence is shifted related to the other.
Properties-
rxy(l)= ryx(-l)
Relation between convolution and correlation-
rxy(l)= x(l)*y(l)
PROGRAM:-
CONCLUSION: -
We got the cross correlation of two sequences and the output is printed.
EXPERIMENT NO- 09
n=-∞
or equivalently
n=∞
n=-∞
Properties-
rxx(l)= rxx(-l)
Relation between convolution and correlation-
rxx(l)=x(l)*x(-l)
PROGRAM:-
CONCLUSION: -
We got the auto correlation of two sequences and the output is printed.
EXPERIMENT NO- 10
PROGRAM:-
p = 0.2; % Probability of success for each trial
n = 10; % Number of trials
k = 0:n; % Outcomes
m = binopdf(k,n,p); % Probability mass vector
bar(k,m) % Visualize the probability distribution
set(get(gca,'Children'),'FaceColor',[.8 .8 1])
grid on
CONCLUSION: -