You are on page 1of 2

EEE324 – Digital Signal Processing

Lab Report # 2
“Introduction to Matlab (II)”

Name Huzaifa Yasir Reg # FA19-BEE-112

Class & Section BEE-5D Semester FA-21


Performed Date 21 09 2021 Submitted Date 26 09 2021

Task -1:
Code:
x=0:pi/100:2*pi;
y1 = 2*cos(x);
y2 = cos(x);
y3 = 0.5*cos(x);
plot(x,y1)
hold on
plot(x,y2)
hold on
plot(x,y3)
xlabel('0 \leq x \leq 2\pi')
ylabel('Cosine functions')
legend('2*cos(x)','cos(x)','0.5*cos(x)')
title('Cosine plots')
axis([0 2*pi -3 3])

Graph:

Task -2:
input:: fprintf: fopen:

1|Page Department of Electrical & Computer Engineering | CUI Wah


EEE324 – Digital Signal Processing

Request the user to Write formatted data Open file, or obtain


input data. to file. information about open
files.
Syntax: Syntax:
Syntax: fileID =
x = input(prompt) fprintf(fileID,formatS fopen(filename)
pec,A1,...,An)
fileID =
fopen(filename,permiss
ion)

fclose:: nargin: nargout::


Close one or more Number of function Number of function
files. input arguments. output arguments.
Syntax: Syntax: Syntax:
fclose(fileID) nargin nargout
fclose('all') nargin(fun) nargout(fun)

Task -3:

code:
clc; clear all; close all;
a=0;
b=2*pi;
n=a:0.01:b;
x1=sin(n);
x2=rand(1,length(n));
x=x1+x2
plot(n,x)
Graph:

2|Page Department of Electrical & Computer Engineering | CUI Wah

You might also like