0% found this document useful (0 votes)
8 views5 pages

Lab 2 Final

DSP Lab 2

Uploaded by

mujtabajamal2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Lab 2 Final

DSP Lab 2

Uploaded by

mujtabajamal2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Department of Computer Engineering

Digital Signal Processing

Course Instructor:

Lab Engineer:

Semester
LAB EXPERIMENT # 02
Graph Plotting in MATLAB

OBJECTIVE:

To learn the plotting of graphs in MATLAB.

HOLD ON COMMAND:

HOLD ON holds the current plot and all axis properties so that subsequent graphing commands add to
the existing graph. HOLD OFF returns to the default mode whereby PLOT commands erase the previous
plots and reset all axis properties before drawing new plots.

Example:

t=0:0.01:10; y1= t+2;


y2= 2*t+5; plot(t, y1)
hold on
plot(t,y2)
grid on

USE OF STEM COMMAND:

STEM (X, Y) plots the data sequence Y at the values specified in X.

MATLAB CODE FOR IMPLEMENTATION:

1. Sine signal & sequences implementation

MATLAB CODE OUTPUT


Cosine Signal & sequence implementation

MATLAB CODE OUTPUT


ContinuousCos Wave
%% C0ntinuous Cos 15
Wave Plot a=10; f=0.1;
10
t=0:0.3:1000;
x=a*cos(2*pi*f*t); subplot(2,1,1); 5

plot(t,x,'k'); grid on; 0


title('Continuous Cos Wave');
xlabel('Time'); -5

ylabel('Amplitude'); -10
axis([0 15 -15 15]);
-15
0 5 10 15

Discrete Cos Wave

%% Discrete Cos Wave Plot


subplot(2,1,2);
stem(t,x,'k'); grid on;
title('Discrete Cos
Wave'); xlabel('Time');
ylabel('Amplitude');
axis([0 15 -15 15]);
PRACTICE QUESTIONS

Q1. Write the difference between stem and plot command. Write the MATLAB code along with the
commenting to show their difference
Ans) Both the plot and stem commands are used for visualizing data, but they serve different purposes:
• plot command: Used to create continuous line plots. It connects the data points with straight
lines, making it ideal for visualizing continuous data or data trends.
• stem command: Used to create discrete plots. It represents data points as stems or lines
originating from the x-axis with circles at the top, which is useful for discrete data or when you
want to emphasize individual data points.

Q2. Plot the graphs of x2, 2x2+4, 2x-10, select appropriate value of x. write comments with the code and
show the output in one figure using hold on command.
Q3. Write the MATLAB code to draw the following signals y1= Asint and y2=Acost on single time axis,
where A represents the student’s roll no.

Rubrics:

Theoretical Setup Troubleshooting Completeness Total Aggregate


concepts preparation

You might also like