Documentos de Académico
Documentos de Profesional
Documentos de Cultura
EXPERIMENT NO. 1
PART A
(PART A: TO BE REFFERED BY STUDENTS)
Generation of a signal (step, ramp, sine, sawtooth and triangular) in continuous and
discrete time. To determine the even and odd components from signals in MATLAB
A1: Aim: Generation of a signal (step, ramp, sine, sawtooth and triangular) in continuous and
discrete time. To determine the even and odd components from signals in MATLAB
A2: Software: MATLAB.
A3: Prerequisite:
Sr. No
1.
Concepts
Sine & Cosine ,plot, stem, subplot
commands
Program No
P1
A4: Outcome:
After successful completion of this experiment students will be able to:
1. To get well familiarized with MATLAB software.
2. Develop and execute MATLAB program using commands and functions.
3. Identify various types of signals.
A5: Theory:
If x and y are two vectors of the same length then plot(x,y) plots x versus y.
For example, to obtain the graph of y = cos(x) from to , we can first define the
vector x with components equally spaced numbers between and , with increment,
say 0.01.
x=-pi:0.01:pi;
We placed a semicolon at the end of the input line to avoid seeing the (long) output. Note that
the smallest the increment, the smoother the curve will be.
The text that appears within single quotes as input to this command, represents the legend
labels. We must be consistent with the ordering of the two curves, so since in the plot
command we asked for cosine to be plotted before sine, we must do the same here. At any
point during a MATLAB session, you can obtain a hard copy of the current plot by either
issuing the command print at the MATLAB prompt, or by using the command menus on the
plot window. In addition, MATLAB plots can by copied and pasted (as pictures) in your
favourite word processor (such as Microsoft Word). This can be achieved using the Edit
menu on the figure window. Another nice feature that can be used in conjunction with plot is
the command grid, which places grid lines to the current axis (just like you have on
graphing paper). Type
help
grid for more information. Other commands for data
visualization that exist in MATLAB include subplot create an array of (tiled) plots in the
same window loglog plot using log-log scales semilogx plot using log scale on the x-axis
semilogy plot using log scale on the y-axis
surf 3-D shaded surface graph surfl 3-D shaded surface graph with lighting mesh 3-D mesh
surface
Common Sequences: Unit Impulse, Unit Step, and Unit Ramp
Common Periodic Waveforms The toolbox provides functions for generating widely used
periodic waveforms: sawtooth generates a sawtooth wave with peaks at 1 and a period of
2. An optional width parameter specifies a fractional multiple of 2 at which the signal's
maximum occurs. square generates a square wave with a period of 2. An optional parameter
specifies duty cycle, the percent of the period for which the signal is positive.
To identify whether the signal is even or odd and also to find the even and odd component
following is the procedure:
x1=A.^(t);
x2=A.^(-t);
if(x2==x1)
The given signal is even signal
Else
if(x2==(-x1))
The given signal is odd signal
Else
The given signal is neither even nor odd
xe=(x1+x2)/2;
xo=(x1-x2)/2;
Part B
(Students must submit the soft copy as per following segments within two hours of the
practical. The soft copy must be uploaded on the Blackboard or emailed to the concerned lab
in charge faculties at the end of the practical in case there is no Black board access available)
Roll No. E059
Class: Btech comp
Date of Experiment:
Grade :
B.1 Software Code written by student:
clear all;
close all;
n1=-50:1:50;
L=length(n1);
for i=1:L;
if n1(i)<=0;
x1(i) =0;
else
x1(i) =n1(i);
end;
end;
subplot(5,6,1);
stem(n1,x1);
ylabel ('Amplitude');
xlabel ('Time');
title('Discrete Ramp Signal');
subplot(5,6,2);
plot(n1,x1);
ylabel ('Amplitude');
xlabel ('Time');
title('Continous Ramp Signal');
%SINE SIGNAL
A=1;
f1=5;
t1=0:.01:1;
x=A*sin(2*pi*f1*t1)
subplot(5,6,7);
stem(t1,x);
ylabel ('Amplitude');
xlabel ('Time');
title ('Discrete Sine Signal');
A=1;
f1=5;
t1=0:.01:1;
x=A*sin(2*pi*f1*t1)
subplot(5,6,8);
plot(t1,x);
ylabel ('Amplitude');
xlabel ('Time');
title('Continous Sine Signal');
y=A*sin(-2*pi*f1*t1)
z=(x+y)/2;
subplot(5,6,9);
stem(t1,z);
ylabel ('Amplitude');
xlabel ('Time');
title('Even component-Dis. Sine Signal');
y=A*sin(-2*pi*f1*t1)
z=(x+y)/2;
subplot(5,6,10);
plot(t1,z);
ylabel ('Amplitude');
xlabel ('Time');
title('Even component-Conti. Sine Signal');
y=A*sin(-2*pi*f1*t1)
z=(x-y)/2;
subplot(5,6,11);
stem(t1,z);
ylabel ('Amplitude');
xlabel ('Time');
title('Odd component-Dis. Sine Signal');
y=A*sin(-2*pi*f1*t1)
z=(x-y)/2;
subplot(5,6,12);
plot(t1,z);
ylabel ('Amplitude');
xlabel ('Time');
title('Odd component-Conti. Sine Signal');
%SAWTOOTH SIGNAL
f=50;
t=0:1:f;
y=sawtooth(t);
subplot(5,6,13);
stem(t,y);
ylabel ('Amplitude');
xlabel ('Time');
title ('Discrete Sawtooth Signal');
f=60;
t=0:0.01:f;
y=sawtooth(t);
subplot(5,6,14);
plot(t,y);
ylabel ('Amplitude');
xlabel ('Time');
title ('Continous Sawtooth Signal');
x=sawtooth(-t);
z=(x+y)/2;
subplot(5,6,15);
plot(t,z);
ylabel ('Amplitude');
xlabel ('Time');
title('Even Conti.Sawtooth Signal');
x=sawtooth(-t);
z=(x+y)/2;
subplot(5,6,16);
stem(t,z);
ylabel ('Amplitude');
xlabel ('Time');
title('Even Dis.Sawtooth Signal');
x=sawtooth(-t);
z=(y-x)/2;
subplot(5,6,17);
plot(t,z);
ylabel ('Amplitude');
xlabel ('Time');
title('Odd Conti. Sawtooth Signal');
x=sawtooth(-t);
z=(y-x)/2;
subplot(5,6,18);
stem(t,z);
ylabel ('Amplitude');
xlabel ('Time');
title('Odd Dis.Sawtooth Signal');
%TRAINGULAR SUGNAL
f=50;
t=0:1:f;
y=sawtooth(t,0.5);
subplot(5,6,19);
stem(t,y);
ylabel ('Amplitude');
xlabel ('Time');
title ('Discrete Triangular Signal');
f=50;
t=0:0.01:f;
y=sawtooth(t,0.5);
subplot(5,6,20);
plot(t,y);
ylabel ('Amplitude');
xlabel ('Time');
title ('Continous Triangular Signal');
n=-10:0.01:10;
L=length(n);
for i=1:L;
if n(i)==0;
x1(i) =1;
else
x1(i) =0;
end;
end;
subplot(5,6,25);
stem(n,x1);
ylabel ('Amplitude');
xlabel ('Time');
B.3 Conclusion: