Thread Subject:
difference equation

Subject: difference equation

From: vikas kumar

Date: 27 Nov, 2010 10:18:03

Message: 1 of 3

how do we solve this difference equation :
y(n) + 1/2y(n-1) + 3/4y(n-2) = x(n)

where x(n)=(1/4)^n for all n>0
       & y(-1)=4 , y(-2)=6

Subject: difference equation

From: Nasser M. Abbasi

Date: 27 Nov, 2010 11:28:31

Message: 2 of 3

On 11/27/2010 2:18 AM, vikas kumar wrote:
> how do we solve this difference equation :
> y(n) + 1/2y(n-1) + 3/4y(n-2) = x(n)
>
> where x(n)=(1/4)^n for all n>0
> & y(-1)=4 , y(-2)=6


2 ways:

appy Z transform, solve for X(z), then find inverse Z transform
look up tables if needed.

or

write y(n)=r^n, to get the auxillary equation,
solve for homogeneous part first

    r^n + (1/2) r^(n-1) + (3/4) r^(n-2) = 0
or
    r^n (1+(1/2)r^-1+(3/4)r^-2) = 0

or for non-trivial solution, need

    1+(1/2)r^-1+(3/4)r^-2 = 0
or
    r^2+(1/2)r+(3/4) = 0

find the roots r1,r2, then you'll get characteristic equation

    yh(n) = c1*r1^n + c2*r2^n

Now Find yp(n) particular (similar way as you would do in continuous time)

add the solutions, y(n) = yh(n) + yp(n)

now,use given initial conditions at n=-1 and n=-2 to solve for
c1 and c2.

--Nasser

Subject: difference equation

From: ali wathab

Date: 28 Jan, 2012 12:25:09

Message: 3 of 3

"vikas kumar" wrote in message <icqlsr$7mp$1@fred.mathworks.com>...
> how do we solve this difference equation :
> y(n) + 1/2y(n-1) + 3/4y(n-2) = x(n)
>
> where x(n)=(1/4)^n for all n>0
> & y(-1)=4 , y(-2)=6

use this program
% This Matlab program implements the general difference equation,

% a0y(n) = b0x(n) + b1x(n-1) + b2x(n-2) + ...+ bM x(n-M)
% -a1y(n-1) - a2y(n-2) - ...- aN y(n-N)

disp(' Implementation of general difference equation'); disp(' ');
b = input('Enter the x coefficients b = ');
a = input('Enter the y coefficients a = ');
x1 = input('enter the input samples x = ');
int = input('enter the intial values int = ');
y= int;
lint=length(int);
x=[zeros(1,lint) x1];
n=length(x);
lb=length(b);
la=length(a);
for s= (lint+1):length(x)
    sumx=0;
    sumy=0;
    for j=2:(la)
        sumy=sumy+a(j)*y(s-j+1);
    end
    for f=1:lb
        sumx=sumx+b(f)*x(s-f+1);
    end
    y(s)=sumx-sumy;
end

disp('The output sequence is y(n) = ');
disp(y);
stem(y);
xlabel('samples n');
ylabel('y(n)');
grid on;
title('Implementation of difference equation');


put y coefficient as a vector from the left side and x coefficient as a vector too from the right side
and define the input vector on how many steps you want it before running the program so as to use it in input vector
 put the initial values y(-2) and y(-1)
and you can see the solution

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
doit4me John D'Errico 27 Nov, 2010 05:55:03
homework Bruno Luong 27 Nov, 2010 05:35:37
rssFeed for this Thread

Contact us