DIGITAL SIGNAL PROCESSING LAB 1
SIGNAL WAVEFORM GENERATION
CODE-
% Exp1- Waveform generation
% a)Sine Wave
% b)Triangular Wave
% c)Exponential
clc;
clear all;
close all;
%Sine Wave
f=1;
t=0:0.01:2;
x=sin(2*pi*f*t);
n=0:1:length(t)-1;
subplot(1,2,1)
plot(t,x)
xlabel('Time')
ylabel('Amplitude')
title('CTS')
grid on
subplot(1,2,2)
stem(n,x)
xlabel('Samples')
ylabel('Amplitude')
title('DTS')
grid on
sgtitle('SINE WAVE')
%Triangular Wave
%t=0:2;
%tr=[0,1,0];
%plot(t,tr);
%y=0:0.1:1;
%plot(y,y);
%n=0:1:length(y)-1;
%stem(n,y);
x1=[0:0.01:1]
x2=[0.99:-0.01:0]
x=[x1,x2]
t=0:0.01:2
n=0:length(t)-1
subplot(1,2,1)
plot(t,x)
xlabel('Time')
ylabel('Amplitude')
title('CTS')
grid on
subplot(1,2,2)
stem(n,x)
xlabel('Samples')
ylabel('Amplitude')
title('DTS')
grid on
sgtitle('TRIANGULAR WAVE')
%Exponential Signal
a = 1; % amplitude
b = 1.5; % growth/decay rate (change value to adjust shape)
t = 0:0.01:2; % time axis
x = a*exp(b*t); % exponential growing signal
%x = a*exp(-b*t); % exponential decaying signal
n = 0:1:length(t)-1;
subplot(1,2,1)
plot(t,x)
xlabel('Time')
ylabel('Amplitude')
title('CTS')
grid on
subplot(1,2,2)
stem(n,x)
xlabel('Samples')
ylabel('Amplitude')
title('DTS')
grid on
sgtitle('EXPONENTIAL SIGNAL')
OUTPUTS-