MATLAB: How to solve difference equation in MATLAB

difference equation

How to solve the difference equation for
yn+1 =5/2 yn +yn-1 ,y0 =y1 =1 in terms of the roots of its characteristic equation in MATLAB ?

Best Answer

An alternative is to use filter()
a = [1 -5/2 -1];
b = 0;
ic = [1 1];
n = 50; % 50 terms
y1 = [ic(1) filter(b, a, ones(1, n-1), ic)];