[go: up one dir, main page]

0% found this document useful (0 votes)
431 views4 pages

MATLAB Signal Processing Guide

This experiment introduced basic discrete-time signal processing operations in MATLAB such as shifting, folding, time scaling, addition, multiplication, and even-odd decomposition of signals. The student generated different signal functions and verified them by plotting the output of operations like shifting, multiplying, adding signals. This included decomposing a signal into its even and odd components and verifying the energy is conserved. The document provided code examples to generate impulse, step, shifted and combined signals and decompose signals into even and odd parts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
431 views4 pages

MATLAB Signal Processing Guide

This experiment introduced basic discrete-time signal processing operations in MATLAB such as shifting, folding, time scaling, addition, multiplication, and even-odd decomposition of signals. The student generated different signal functions and verified them by plotting the output of operations like shifting, multiplying, adding signals. This included decomposing a signal into its even and odd components and verifying the energy is conserved. The document provided code examples to generate impulse, step, shifted and combined signals and decompose signals into even and odd parts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Experiment 3:

Discrete-Time Signal Processing Operation


John Paul E. Ocampo
Electronics Engineering Department
University of Santo Tomas

I.

Introduction

MATLAB has a lot of different functions


that we can use to manipulate signals.
The most basic signal operations are
Shifting, Folding, time scaling, signal
addition, signal multiplication and evenodd
decomposition.
The
Shifting
functions used to delay or advance
samples by a certain constant k. Timescaling are used in Down-sampling or
Up-sampling, Replacing n by a certain
constant n. Addition of Discrete Time
signals which is the summation of
several signals whose value at any
instant that is equal to the sum of the
values of two or more signals at that
instant. Multiplication of Discrete Time
signals is the product of two or more
signals. Amplitude scaling of DT signal
is the amplitude scaling of a signal by a
constant A.

Experiment 3 introduced the basic


functions that we will be using
throughout the whole semester. These
functions are used to manipulate
Discrete time signals. Some of these
functions are shifting, folding, time
scaling, addition of two or more discrete-

time signals, multiplication of two or


more dicrete-time signals and Amplitude
scaling of discrete-time signals.
IV.

Appendix

1. Generate an impulse signal (nn0) over the interval n1 to n2


[x,n] = impseq(n0,n1,n2)
(nn0)=1, n=n0
0, n=n0
Codes:

II.

Experimentation
function [x,n] = impseq(n0,n1,n2)

In this experiment we were tasked to


generate different signals in a function
file, which made it easier to evaluate the
other problems because it was the most
convenient approach to enter the next
required values by substituting the
generated function files of the different
signals.
III.

Conclusion

if ((n0 < n1) | (n0 > n2) | (n1 > n2))


error('the input arguments entered are
invalid')
end
n =[n1:n2]; x =[(n-n0) == 0];
a. generate sequence u(n-n0) over the
interval n1 to n2
[x,n] = stepseq(n0,n1,n2)
u(nn0)=1, nn0
Codes:

function [x,n] = stepseq(n0,n1,n2)


if ((n0 < n1) | (n0 > n2) | (n1 > n2))
error('input arguments are invalid')
end
n =[n1:n2];
x =[(n-n0) >= 0]
b. generate sequence y(n) = x(n0 m)
[y,n] = sigshift(x,m,n0)
Codes:
function [y,n] = sigshift(x,m,n0)
n = m+n0;
y = x;
c. generates sequence y(m) = x(n)
[y,m] = sigfold(x,n)
Codes:
function [y,n] = sigfold(x,n)
y =fliplr(x); n =-fliplr(n);
d. generate sequence y(n) = x1(n) +
x2(n) [y,n] = sigadd(x1,n1,x2,n2)
Codes:
function [y,n] = sigadd(x1,n1,x2,n2)
n = min(min(n1),min(n2)):max(max(n1),
max(n2));
a = zeros(1,length(n));
b = a; a(find((n>=min(n1))&
(n<=max(n1))==1))=a1;
y2(find((n>=min(n2))&(n<=max(n2))==1)
)=a2;
y = a+b;
e. generate sequence y(n) = x1(n) x2(n)
[y,n] = sigmult(x1,n1,x2,n2)
Codes:
function [y,n] = sigmult(x1,n1,x2,n2)
n = min(min(n1),min(n2)):
max(max(n1),max(n2));
a = zeros(1,length(n));
b = y1;

y1(find((n>=min(n1))&
(n<=max(n1))==1))=x1;
b(find((n>=min(n2))&(n<=max(n2))==1))
=a2;
y = a .* b;
f. generate
components
evenodd(x,n)

the even and odd


of x(n) [xe,xo,n] =

Codes:
function [xe, xo, m] = evenodd(x,n)
if any(imag(x) ~= 0)
end
m = -fliplr(n);
m1 = min([m,n]); m2 = max([m,n]);
m = m1:m2;
nm = n(1)-m(1); n1 = 1:length(n);
a1 = zeros(1,length(m)); a1(n1+nm) = x;
x = a1;
xe = 0.5*(x + fliplr(x));
xo = 0.5*(x - fliplr(x));
2. Verify the function files created in
problem (1) by plotting (using stem
function) the sequence generated by the
following operations
a..x(n) = 2(n)2(n1)+3(n2)+
3(n3)4(n5) , for 2< n < 7 use
impseq and sigadd functions
Codes:
[xa,n]=impseq(0,-2,7);
[x1,n1]=impseq(1,-2,7);
[x2,n2]=impseq(2,-2,7);
[x3,n3]=impseq(3,-2,7);
[x4,n4]=impseq(5,-2,7);
x1a= 2.*xa;
x2a=-2.*x1;
x3a=3.*x2;
x4a=3.*x3;
x5a=-4.*x4;
[x1b,n]=sigadd(x1a,n,x2a,n1);
[x2b,n]=sigadd(x3a,n2,x4a,n3);
[x1c,n]=sigadd(x1b,n,x5a,n4);

[x,n]=sigadd(x1c,n,x2b,n);
stem(n,x);

b. y(n) = x(4 n)x(2 n) , where x(n) is


the sequence generated in 2.a. use
sigshift, sigfold and sigmult functions
Codes:
[x1,n1]= sigfold(x,n);
[x1,n1]=sigshift(x1,n1,4);
[x2,n2]=sigfold(x,n);
[x2,n2]=sigshift(x2,n2,-2);
[y,n]=sigmult(x1,n1,x2,n2);
stem(n,y)

[d,dn]=sigadd(b,bn,-c,cn);
[x,n]=sigmult(a,an,d,dn);
stem(n,x);

d. Decompose the signal


for 50 < n < 50 to its even and odd
components and verify that the energy
of x(n) is equal to the sum of energy of
its even and odd components.
Determine and plot (stem) the following
functions:
1. x(n)
2. even component
3. odd component
4. sum of even and odd
components, x(n)
Codes:
n=-50:50;
x = (0.97.^abs(n)).*cos(.0009.*pi.*n.^2+
(pi./3)).*sin(.005.*pi.*n+(pi./4));
[xe,xo,n]=evenodd(x,n);
[s,n]=sigadd(xe,n,xo,n);
subplot(4,1,1); stem(n,x);
subplot(4,1,2); stem(n,xe);
subplot(4,1,3); stem(n,xo);
subplot(4,1,4); stem(n,s);

c. use sigshift, stepseq and sigmult


functions where r(n) = nu(n), is a unit
ramp function
Codes:
[a,an]=stepseq(0,-2,7);
a=an.*a;
[a,an]=sigshift(a,an,-1);
[b,bn]=stepseq(0,-2,7);
[c,cn]=stepseq(1,-2,7);

You might also like