0% found this document useful (0 votes)
12 views12 pages

Ss Exp-3

The document outlines an experiment focused on performing various operations on signals and sequences using MATLAB, including addition, multiplication, scaling, shifting, and folding. It provides a detailed procedure for executing these operations, along with MATLAB code examples and expected outputs. The results demonstrate the successful application of these operations on different signal types and sequences.

Uploaded by

dattavakul8
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)
12 views12 pages

Ss Exp-3

The document outlines an experiment focused on performing various operations on signals and sequences using MATLAB, including addition, multiplication, scaling, shifting, and folding. It provides a detailed procedure for executing these operations, along with MATLAB code examples and expected outputs. The results demonstrate the successful application of these operations on different signal types and sequences.

Uploaded by

dattavakul8
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/ 12

EXPERIMENT NO-3

VARIOUS OPERATIONS ON SIGNALS AND SEQUENCES

AIM:-
To performs operations on signals and sequences such as addition, multiplication, scaling,
shifting, folding, computation of energy and average power.

SOFTWARE REQURIED:-
1.MATLAB R2010a.

2. Windows 11.

THEORY:-
Basic Operation on Signals:

Time shifting: y(t)=x(t-T)The effect that a time shift has on the appearance of a signal If T
is a positive number, the time shifted signal, x(t-T) gets shifted to the right, otherwise it gets
shifted left.

Signal Shifting and Delay:

Shifting: y(n)={x(n-k)}; m=n-k; y=x;


Time reversal: Y(t)=y(-t) Time reversal flips the signal about t = 0

𝒙(𝒏) 𝒙(𝒏 − 𝑻)

𝒛𝑻

Signal Addition and Subtraction:


Addition: any two signals can be added to form a third signal, z (t) = x (t) + y (t)

Signal Amplification/Attenuation:

Multiplication/ Division:
of two signals, their product is also a signal. z (t)=x(t) y (t)

folding:
y(n)={x(-n)} : y=fliplr(x); n=-fliplr(n):

PROCEDURE:-

 Open MATLAB
 Open new M-file
 Type the program
 Save in current directory
 Compile and Run the program
 For the output see comm
PROGRAM:
clc; %clear command window

close all; %close all figure windows

clear all; %clear workspace variables

t=0:0.01:5; %define time vector from 0 to 5 with step of 0.01

x1=sin(2*pi*t); %define sine function

x2=square(2*pi*t); %define square function

subplot(2,2,1); %create a subplot, first figure in 2x2 grid

plot(t,x1); %plot sine wave

xlabel('time'); %label x-axis

ylabel('amplitude'); %label y-axis


title('signal1:sine wave of frequency 1HZ'); %title the plot

subplot(2,2,2); %create a subplot, second figure in 2x2 grid

plot(t,x2); %plot square wave

xlabel('time'); %label x-axis

ylabel('amplitude'); %label y-axis

title('signal2:square wave of frequency 3HZ'); %title the plot

%ADDITION OF SIGNALS
y1=x1+x2; %adding both signals

subplot(2,2,3); %create a subplot, third figure in 2x2 grid

plot(t,y1); %plot the resultant signal

xlabel('time'); %label x-axis

ylabel('amplitude'); %label y-axis

title('addition of two signals'); %title the plot

%PRODUCT OF TWO SIGNALS


y2=x1.*x2; %product of two signals

subplot(2,2,4); %create a subplot, fourth figure in 2x2 grid

plot(t,y2); %plot the resultant signal


xlabel('time'); %label x-axis
ylabel('amplitude'); %label y-axis

title('product of two signals'); %title the plot

OUTPUT:

%SCALING OF SINE SIGNAL


a=5; %define scaling factor

y3=a*x1; %scale the signal

figure; %create another figure window

subplot(2,2,1); %create a subplot, first figure in 2x2 grid

plot(t,x1); %plot the i/p signal

xlabel('time'); %label x-axis

ylabel('amplitude'); %label y-axis

title('sine wave of frequency 1HZ'); %title the plot

subplot(2,2,2); %create a subplot, second figure in 2x2 grid

plot(t,y3); %plot the scaled signal


xlabel('time'); %label x-axis

ylabel('amplitude'); %label y-axis

title('amplified sine signal'); %title the plot

%FOLDING OF SQUARE SIGNAL


L1=length(x2); %create a variable to know the length of square wave
nx=0:L1-1; %define nx vector

subplot(2,2,3); %create a subplot, third figure in 2x2 grid

plot(nx,x2); %plot the scaled signal

xlabel('x2'); %label x-axis

ylabel('amplitude'); %label y-axis

title('square wave of frequency 1HZ'); %title the plot

y4=fliplr(x2); %fold the signal

nf=-fliplr(nx);
subplot(2,2,4); %create a subplot, fourth figure in 2x2 grid

plot(nf,y4); %plot the folded signal

xlabel('nf'); %label x-axis

ylabel('amplitude'); %label y-axis

title('folded signal'); %title the plot

OUTPUT:

%SHIFTING
figure; %create another figure window

N=100; %define length of step function


t1=1:100; %define time vector from 1 to 100
x3=ones(1,N); %define unit step function

subplot(3,1,1); %create a subplot, first figure in 3x1 grid

plot(t1,x3); %plot the unit step signal

xlabel('time t1'); %label x-axis

ylabel('amplitude'); %label y-axis

title('unit step signal'); %title the plot

subplot(3,1,2); %create a subplot, second figure in 3x1 grid

plot(t1+5,x3); %plot the shifted signal


xlabel('t1+5'); %label x-axis

ylabel('amplitude'); %label y-axis

title('left shifted signal'); %title the plot

subplot(3,1,3); %create a subplot, third figure in 3x1 grid

plot((t1-5),x3); %plot the shifted signal

xlabel('t1-5'); %label x-axis

ylabel('amplitude'); %label y-axis

title('right shifted signal'); %title the plot

OUTPUT:
%SEQUENCE OPERATIONS
n1=1:1:10; %define discrete time vector from 1 to 10 with a step of 1

s1=[5 4 3 2 1 5 4 3 2 1]; %sequence generation

figure; %create another figure window

subplot(2,2,1); %create a subplot, first figure in 2x2 grid

stem(n1,s1); %stem plot the sequence

xlabel('n1'); %label x-axis

ylabel('amplitude'); %label y-axis

title('input sequence 1'); %title the plot


n2=1:1:10; %define discrete time vector from 1 to 10 with a step of 1

s2=[5 4 3 2 1 2 3 4 5 6]; %sequence generation

subplot(2,2,2); %create a subplot, second figure in 2x2 grid

stem(n2,s2); %stem plot the sequence

xlabel('n2'); %label x-axis

ylabel('amplitude'); %label y-axis

title('input sequence 2'); %title the plot

%ADDITION
s3=s1+s2; %addition of sequences

subplot(2,2,3); %create a subplot, third figure in 2x2 grid

stem(n1,s3); %stem plot the sequence

xlabel('n1'); %label x-axis

ylabel('amplitude'); %label y-axis

title('sum of two sequences'); %title the plot

%PRODUCT
s3=s1.*s2; %product of sequences

subplot(2,2,4); %create a subplot, fourth figure in 2x2 grid

stem(n1,s3); %stem plot the sequence


xlabel('n1'); %label x-axis
ylabel('amplitude'); %label y-axis
title('product of two sequences'); %title the plot

OUTPUT:

%SCALING
figure; %create another figure window

subplot(2,2,1); %create a subplot, first figure in 2x2 grid

stem(n1,s1); %stem plot the sequence

xlabel('n1'); %label x-axis

ylabel('amplitiude'); %label y-axis

title('input sequence 1'); %title the plot


s5=4*s1; %scale the sequence

subplot(2,2,2); %create a subplot, second figure in 2x2 grid

stem(n1,s5); %stem plot the sequence

xlabel('n1'); %label x-axis

ylabel('amplitude'); %label y-axis


title('scaled sequence 1'); %title the plot

subplot(2,2,3); %create a subplot, third figure in 2x2 grid


stem(n1-2,s1); %stem plot the sequence
xlabel('n1'); %label x-axis

ylabel('amplitude'); %label y-axis

title('right shifted sequence 1'); %title the plot

subplot(2,2,4); %create a subplot, fourth figure in 2x2 grid

stem(n1+4,s1); %stem plot the sequence

xlabel('n1'); %label x-axis

ylabel('amplitude'); %label y-axis

title('left shifted sequence 1'); %title the plot

OUTPUT:

%FOLDING OF A SEQUENCE
L2=length(s2); %create a variable to know the length of sequence

nx1=0:L2-1; %define nx1 vector

figure; %create another figure window

subplot(2,1,1); %create a subplot, first figure in 2x2 grid

stem(nx1,s2); %stem plot the sequence

xlabel('nx1'); %label x-axis

ylabel('amplitiude'); %label y-axis


title('input sequence 2'); %title the plot
s6=fliplr(s2); %fold the sequence

nf2=-fliplr(nx1);

subplot(2,1,2); %create a subplot, first figure in 2x2 grid

stem(nf2,s6); %stem plot the sequence

xlabel('nf2'); %label x-axis

ylabel('amplitiude'); %label y-axis

title('folded sequence '); %title the plot

OUTPUT:

%program to calculate energy of sequence-1


z1=sin(2*pi*20*t).^2; % create a variable to square the signal

e1=sum(abs(z1).^2); %summation of all sequences squares

e1 %display the energy

%program to calculate energy of sequence-2


t=0:pi:10*pi; %define time interval
z2=-cos(2*pi*50*t).^2; % create a variable to square the signal
e2=sum(abs(z2).^2); %summation of all sequences squares

e2 %display the energy

%program to calculate power of sequence-1


p1=(sum(abs(z1).^2)/length(z1)); %calculate power of sequence

p1 %display power

%program to calculate power of sequence-2


p2=(sum(abs(z2).^2)/length(z2)); %calculate power of sequence

p2 %display power

OUTPUT:
e1=

187.5000

e2=

4.0388

p1=
0.3743

p2=

0.3672

RESULT:
Various operations on signals and sequences are performed.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy