blob: b7a05a065df3c0d3d97dcfabf07846f17a3afa53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
//Example 9.5
//Difference Equation
//Page no. 291
clc;clear;close;
y(1)=1.5;y(2)=3;
n=poly(0,'n')
x=poly(0,'x')
f=x^2-2*x+1;
disp(f)
x=roots(f)
disp(x,"x = ")
A=[1,1;1,2];
B=[y(1);y(2)]
C=inv(A)*B
for i=1:2
printf('\nc(%i) = %g\n',i,C(i))
end
yn=C(1)+C(2)*n
disp(yn,"yn = ")
|