Digital Signal Processing Reference
In-Depth Information
>> x(2)=4*cos(pi/8)
>> for n = 3:11
n1= n-1
x(n) = 4*cos(pi*n1/8)
y(n) = y(n-1) + 2*y(n-2) + x(n-2)
end
>> y; displays the vector y ( n )
>> stem(y); plots the vector y ( n )
>> xlabel('n'); defines the x -axis on plot
>> ylabel('y(n)'); defines the y -axis on plot
>> title('system output y(n)'); defines the title of
the plot
Example: Find the system output y ( n ), 0
10, of a LTI system when the
input x ( n ) = (0.8) n [ u ( n ) - u ( n-5 )] and the impulse response h ( n ) = (0.5) n [ u ( n ) -
u ( n - 10)]. Plot the vectors x , h , and y on the same page using subplot
commands.
n
Solution:
FOR loop approach
>> for n = 1:10
n1(n)= n-1
h(n) = (0.5)^n1(n)
end
>> for n = 1:5
n2(n)= n-1
x(n) = (0.8)^n2(n)
end
>> y=conv(x, h); performs the convolution of the
vectors x and h
>> n4 = size(n1)+size(n2)-1; calculates the size of
the output vector y
>> n3 = 0:n4-1
>> subplot(3,1,1); divides the page into 3 rows and 1
column format
>> stem(n1,x); plots the input vector x
>> subplot(3,1,2)
>> stem(n2,h); plots the impulse response vector h
Search WWH ::




Custom Search