matlab GM(2,1)模型

GM(2,1)模型

clc,clear;
x0=[41,49,61,78,96,104];
n=length(x0);
x1=cumsum(x0)
a_x0=diff(x0)'
z=0.5*(x1(2:end)+x1(1:end-1))';
B=[-x0(2:end)',-z,ones(n-1,1)];
u=B\a_x0
syms x(t)
x=dsolve(diff(x,2)+u(1)*diff(x)+u(2)*x==u(3),x(0)==x1(1),x(5)==x1(6));%求符号解
xt=vpa(x,6)
yuce=subs(x,t,0:n-1);
yuce=double(yuce)
x0_hat=[yuce(1),diff(yuce)];
x0_hat=round(x0_hat)
epsilon=x0-x0_hat
delta=abs(epsilon./x0)

result

x1 =

41    90   151   229   325   429

a_x0 =

 8
12
17
18
 8

u =

  -1.0922
   0.1959
  -31.798

xt =

203.849exp(0.226223t) - 0.532506exp(0.865973t) - 162.317

yuce =

       41       92.015       155.16       232.37       324.52          429

x0_hat =

41    51    63    77    92   104

epsilon =

 0    -2    -2     1     4     0

delta =

        0     0.040816     0.032787     0.012821     0.041667            0

你可能感兴趣的:(matlab,matlab)