Digital Signal Processing Reference
In-Depth Information
FOR loop approach:
>> for n = 1:1: 11
n1(n) = n - 1
y(n) = n1(n) * sin(pi*n1(n)/2)
end
>> y; gives the vector y
>> stem(n1,y); plots the signal y ( n ) vs. n with
impulses
Vector approach:
>> n = 0 : 10; creates the vector n
>> y = n.*sin(pi*n/2); obtains the vector y
>> stem(n,y); plots the signal y ( n ) vs. n with impulses
Basic Signal Operations In MATLAB
Example: Define the discrete-time signal x ( n ) = n u ( n ) in a vector in the
range 0
n
10 and plot the signal.
Solution:
>> n = 0:10; defines the vector n of length 11
>> u (1:11) = ones(1,11); defines the unit step
vector u of length 11
>> x = n. *u; defines the product n u ( n )
>> stem(n,x); plots the discrete signal x ( n )
Exercise 2: Working with vectors and matrices
Write a MATLAB program to sketch the following discrete-time
signals in the time range of - 10
10. Please label all the graph
axes clearly. If the sequence is complex, plot the magnitude and angle
separately.
i.
n
x ( n ) = u ( n ) - u ( n - 3)
ii.
n /3) u ( n )
iii. x ( n ) = 0.5 n e j π n /2
x ( n ) = sin(
π
There are two main forms of vector or matrix multiplication. In
MATLAB, if two vectors, a and b (both vectors of size 1 xN ) are given,
then the two possible MATLAB multiplication commands are: y =
a*b and y = a.*b.
Search WWH ::




Custom Search