0% found this document useful (0 votes)
57 views13 pages

Task 1:: Clear All Close All CLC Shakaib (0:2:20) Display (Shakaib)

1) The document describes 10 tasks from a digital signal processing lab session involving generating different types of signals and waves using Matlab code. 2) The tasks include generating a sine wave function, plotting multiple waves on the same figure, converting between Fahrenheit and Celsius, and displaying even numbers between 0 and 20. 3) A function is also created to calculate the solutions to a quadratic equation based on input coefficients.

Uploaded by

shakaib
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)
57 views13 pages

Task 1:: Clear All Close All CLC Shakaib (0:2:20) Display (Shakaib)

1) The document describes 10 tasks from a digital signal processing lab session involving generating different types of signals and waves using Matlab code. 2) The tasks include generating a sine wave function, plotting multiple waves on the same figure, converting between Fahrenheit and Celsius, and displaying even numbers between 0 and 20. 3) A function is also created to calculate the solutions to a quadratic equation based on input coefficients.

Uploaded by

shakaib
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/ 13

DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED

(EL-303) ROLL NO.:2018-EL-003

TASK 1:
▪ Make a program on script file that takes temperature in Fahrenheit and gives output in
centigrade.
𝟓
𝑪= ∗ (𝑭 − 𝟑𝟐)
𝟗
PROGRAM:
f=input('ENTER VALUE OF TEPERATURE IN FAHRENHEIT= ')
C=5/9*(f-32)
OUTPUT:

TASK 2:
▪ Display all even numbers from 0 to 20. Store the values in a variable of your full
name.
PROGRAM:
clear all
close all
clc
shakaib=[0:2:20];
display(shakaib)

OUTPUT:

DEPARTMENT OF ELECTRICAL ENGINEERING


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED
(EL-303) ROLL NO.:2018-EL-003

TASK 3:
▪ Generate a script file which produces tangent and exponential signal on the same
figure.
PROGRAM:
clc
t=[0:0.01:10];
y1=tan(t);
y2=exp(t);
plot(t,y1,'linewidth',3)
hold on
plot(t,y2,'linewidth',3)
legend('TANGENT WAVE','EXPONENTIAL WAVE')

OUTPUT:

DEPARTMENT OF ELECTRICAL ENGINEERING


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED
(EL-303) ROLL NO.:2018-EL-003

TASK 4:
▪ Plot sine and cosine waves simultaneously, on same figure through ‘hold on’
command and use ‘legend’ command.
PROGRAM:
clear all
close all
clc
t=[0:0.01:10];
y1=sin(t);
y2=cos(t);
plot(t,y1,'linewidth',3)
hold on
plot(t,y2,'linewidth',3)
legend('SINE WAVE','COSINE WAVE')

OUTPUT:

DEPARTMENT OF ELECTRICAL ENGINEERING


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED
(EL-303) ROLL NO.:2018-EL-003

TASK 5:
▪ Generate Sine, Cosine, Tangent, Cotangent, Secant and Cosecant waveforms of 3Hz
using subplot command. If A=2, f=3, t=0:0.01:1 and argument for tan and cot is πft.
To generate these figures following commands could be used:
Sine wave: sin cosecant wave: csc

cosine wave: cos secant wave: sec

tangent wave: tan cotangent wave: cot

PROGRAM:
t=[0:0.01:1]
f=3
y1=2*sin(2*pi*f*t)
subplot(2,3,1)
plot(t,y1)
legend('sine wave')
y2=2*cos(2*pi*f*t)
subplot(2,3,2)
plot(t,y2)
legend('cos wave')
y3=2*sec(2*pi*f*t)
subplot(2,3,3)
plot(t,y3)
legend('secant wave')
y4=2*csc(2*pi*f*t)
subplot(2,3,4)
plot(t,y4)
legend('cosecant wave')
y5=2*tan(pi*f*t)
subplot(2,3,5)
plot(t,y5)
legend('tangent wave')
y6=2*cot(pi*f*t)
subplot(2,3,6)
plot(t,y6)
legend('cotangent wave')

DEPARTMENT OF ELECTRICAL ENGINEERING


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED
(EL-303) ROLL NO.:2018-EL-003

OUTPUT:

DEPARTMENT OF ELECTRICAL ENGINEERING


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED
(EL-303) ROLL NO.:2018-EL-003

TASK 6:
▪ Generate a script file which produces a sine wave with 2Hz, 5Hz, 10Hz and 20Hz
frequencies on a single figure by using subplot command. Label the subplots with the
relevant frequency to distinguish the signals clearly. And apply the following
formatting to each.
• Line color
• Style (Line type)
• Marker Edge color, Marker Face color, Marker size
• Switch on the grid
• Label X-axis and Y-axis
• Give title to the generated figures.
PROGRAM:
t=[0:0.01:1]
f1=2
x1=2*sin(2*pi*f1*t)
subplot(2,2,1)
plot(t,x1,'-
.*m','linewidth',3,'MarkerEdgeColor','g','MarkerFaceColor','k','MarkerSize',2)
xlabel('time')
ylabel('amplitude')
legend('FREQUENCY=2HZ')
grid on
f2=5
x2=2*sin(2*pi*f2*t)
subplot(2,2,2)
plot(t,x2,'-dc','linewidth',3,'MarkerEdgeColor','g','MarkerFaceColor','k','MarkerSize',2)
xlabel('time')
ylabel('amplitude')
legend('FREQUENCY=5HZ')
grid on
f3=10
x1=2*sin(2*pi*f3*t)
subplot(2,2,3)
plot(t,x1,':>r','linewidth',3,'MarkerEdgeColor','g','MarkerFaceColor','k','MarkerSize',2)
xlabel('time')
ylabel('amplitude')
DEPARTMENT OF ELECTRICAL ENGINEERING
SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED
(EL-303) ROLL NO.:2018-EL-003

legend('FREQUENCY=10HZ')
grid on
f4=20
x1=2*sin(2*pi*f4*t)
subplot(2,2,4)
plot(t,x1,'--
<g','linewidth',3,'MarkerEdgeColor','g','MarkerFaceColor','k','MarkerSize',2)
xlabel('time')
ylabel('amplitude')
legend('FREQUENCY=20HZ')
grid on

OUTPUT:

DEPARTMENT OF ELECTRICAL ENGINEERING


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED
(EL-303) ROLL NO.:2018-EL-003

TASK 7:
▪ Produce a triangular, trailing edge saw-tooth and leading-edge saw-tooth wave by
using ‘sawtooth’ command.
FOR LEADINGEDGE:
PROGRAM:
t=[-5:0.01:40];
x=sawtooth(t,0.01);
plot(t,x,'-r','linewidth',4)
xlabel('TIME')
ylabel('AMPLITUDE')
legend('LEADING EDGE SAWTOOTH WAVE')
grid on

OUTPUT:

DEPARTMENT OF ELECTRICAL ENGINEERING


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED
(EL-303) ROLL NO.:2018-EL-003

FOR TRAILINGEDGE:
PROGRAM:
t=[-5:0.01:30];
x=sawtooth(t,1);
plot(t,x,'-m','linewidth',4)
xlabel('TIME')
ylabel('AMPLITUDE')
legend('TRAILING EDGE SAWTOOTH WAVE')
grid on

OUTPUT:

FOR TRIANGULAR:
PROGRAME:
t=[-5:0.01:30];
x=sawtooth(t,0.5);
plot(t,x,'-b','linewidth',4)
xlabel('TIME')
ylabel('AMPLITUDE')
legend('TRAIANGULAR')
grid on
DEPARTMENT OF ELECTRICAL ENGINEERING
SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED
(EL-303) ROLL NO.:2018-EL-003

OUTPUT:

TASK 8:
▪ Use ‘square’ command to generate a Square wave and Rectangular wave.
FOR SQUARE WAVE:
PROGRAM:
t=(0:0.01:10);
x=square(t,50);
plot(t,x,'-b','linewidth',4)
axis([0 10 -2 2])
xlabel('TIME')
ylabel('AMPLITUDE')
legend('SQUARE Wave')
grid on

DEPARTMENT OF ELECTRICAL ENGINEERING


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED
(EL-303) ROLL NO.:2018-EL-003

OUTPUT:

FOR RECTANGULR WAVE:


PROGRAME:
t=(0:0.01:14);
x=square(t,95);
plot(t,x,'-Y','linewidth',4)
axis([0 14 -2 2])
xlabel('TIME')
ylabel('AMPLITUDE')
legend('Rectangular Wave')
grid on

OUTPUT:

DEPARTMENT OF ELECTRICAL ENGINEERING


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED
(EL-303) ROLL NO.:2018-EL-003

TASK 9:
▪ Generate a function which produces a sine wave by accepting frequency and
amplitude as input arguments and return its plot for the inputted parameters.
PROGRAM:
function y=sinewave(AMP,FREQ)
t=0:0.01:1;
y=AMP*sin(2*pi*FREQ*t);
plot(t,y,'-b','linewidth',4)
xlabel('TIME')
ylabel('AMPLITUDE')
grid on
end

OUTPUT:

DEPARTMENT OF ELECTRICAL ENGINEERING


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
DIGITAL SIGNAL PROCESSING LAB SESSION #02 NAME:SYED SHAKAIB AHMED
(EL-303) ROLL NO.:2018-EL-003

TASK 10:
▪ Make a function file which gives quadratic equation and call function by using script
file through input command.
−𝑏 ± √𝑏 2 − 4𝑎𝑐
𝑥=
2𝑎
PROGRAM:
function quadratic(a,b,c)
e=sqrt((b*b)-4*a*c);
p=(-b+e)/2*a
q=(-b-e)/2*a
end

OUTPUT:

DEPARTMENT OF ELECTRICAL ENGINEERING


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY

You might also like