Documente Academic
Documente Profesional
Documente Cultură
2
Aim: - Operation on discrete- time signals 1. Signal addition
This is sample by sample addition given by
1. y (n) x1 ( n) x2 ( n)
Solution
x1=[1 2 3 4 5 6 7 6 5 4]; n1=-2:7; x2=[-1 2 0 4 5 -2 7 6 8 4 -3 4]; n2=-4:6; [y,n]=sigadd(x1,n1,x2,n2); subplot(2,2,1);stem(n1,x1) title('First seq. x1(n)'); xlabel('sample'); ylabel('amplitude'); subplot(2,2,2);stem(n2,x2) title('Second seq. x2(n)'); xlabel('sample'); ylabel('Amplitude'); subplot(2,1,2);stem(n,y) title('addition of signal') xlabel('sample'); ylabel('Amplitude');
2.
Signal Multiplication
This is sample by sample multiplication given by
{x1(n)}.{x2(n)}={x1(n)x2(n)}
In MATLAB it is implemented by the array operator .*. Write a function for the multiplication of two sequences x1(n) and x2(n).
{x(n)}={ x(n)}
An arithmetic operator * is used to implement the scaling operation in MATLAB.
4.
Shifting
In this operation each sample of x(n) is shifted by an amount k to obtain a shifted sequence y(n).
y(n}={ x(n-k)
If we let m=n-k, then n=m+k and above operation is given by
y(m+k)={x(m)}
Write a MATLAB function to shift the given sequence by k amount. function [y,n]=sigshift(x,m,n0) n=m+n0; y=x;
5.
Folding
In this operation each sample of x(n) is flipped around its origin n=0 to obtained folded sequence y(n).
y(n)={x(-n)}
Hint: Use fliplr( ) function. function [y,n] =sigfold(x,n) y=flipr(x); n=-flipr(n);
x( n) {1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2,1}
1. x1 ( n) x(3 n)