0% found this document useful (0 votes)
9 views3 pages

DSP Project of Chapter 2-Including Example

The document outlines a MATLAB project involving the generation and plotting of a discrete-time exponential signal and the impulse response of a given differential equation. It includes instructions for implementing the recursive function and using MATLAB's filter function to compute the impulse response. Additionally, it specifies submission guidelines for the program and results to an FTP site within two weeks of assignment.

Uploaded by

n26120579
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)
9 views3 pages

DSP Project of Chapter 2-Including Example

The document outlines a MATLAB project involving the generation and plotting of a discrete-time exponential signal and the impulse response of a given differential equation. It includes instructions for implementing the recursive function and using MATLAB's filter function to compute the impulse response. Additionally, it specifies submission guidelines for the program and results to an FTP site within two weeks of assignment.

Uploaded by

n26120579
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/ 3

MATLAB Project of Chapter 2

1. Write a MATLAB program to generate a discrete-time exponential signal. Use this


function to plot the exponential x[n]=(0.9)n over the range n=0, 1, 2, …, 20.

2. Given a differential equation:


𝜋 1
𝑦[𝑛] − 1.8 cos ( ) 𝑦[𝑛 − 1] + 0.81𝑦[𝑛 − 2] = 𝑥[𝑛] + 𝑥[𝑛 − 1]
16 2
generate and plot the impulse response h[n] of the difference equation
𝜋
(a) using recursion 𝑦[𝑛] = 1.8 cos (16) 𝑦[𝑛 − 1] − 0.81𝑦[𝑛 − 2] + 𝑥[𝑛] +
1
𝑥[𝑛 − 1]
2
(b) using the filter function.
Plot h[n] in the range of −10 ≤ 𝑛 ≤ 100.

Please upload your program and the results to the ftp site within two weeks after the
date of project assignment. The ftp site can be found at the course website.
Example

Given a differential equation: y[n] - 0.9y[n-1] + 0.81y[n-2] = x[n] - x[n-2]

a. Find the impulse response for h[n], n=0,1,2 using recursion.

b. Find the impulse response using MATLAB command filter.

Answer:

This is actually quite simple, because the differential equation contains the body of the

recursive function almost entirely: y[n] = 0.9y[n-1] - 0.81y[n-2] + x[n] - x[n-2]

The parts in bold are actually the recursive calls! What you need to do is to build a function

(let's call it func) that receives x and n, and calculates y[n]:

function y = func(x, n)

if (n < 0)

%# Handling for edge case n<0

return 0

else if (n == 0)

%# Handling for edge case n=0

return x(0)

else

%# The recursive loop

return 0.9 * func(x, n-1) - 0.81 * func(x, n-2) + x(n) - x(n-2)

end
Note that it's pseudo-code, so you still have to check the edge cases and deal with the

indexation (indices in MATLAB start with 1 and not 0!).

Using filters

The response of a digital filter is actually the y[n] that you're looking for. As you probably know

from lesson, the coefficients of that filter would be the coefficients specified in the differential

equation. MATLAB has a built-in function filter that emulates just that, so if you write:

B = [1, 0, 1]; %# Coefficients for x

A = [1, 0.9, -0.81]; %# Coefficients for y

y = filter(B, A, x);

You'd get an output vector which holds all the values of y[n].

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