matlab解决回归问题

来源:百度知道 编辑:UC知道 时间:2024/06/25 16:34:44
年份 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004
公交数量 40.33 39.09 39.94 40.07 40.23 42.91 43.22 43.20 43.11 43.90 44.52 46.71 50.47 55.72 74.21 97.80 123.47 145.18 160.22 176.31(单位是10平方)
问题:预测05-15年公交数量。

求个程序,,,要直接放在matlab上就可以运行的,,谢谢了

year=[1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004];
num=[40.33 39.09 39.94 40.07 40.23 42.91 43.22 43.20 43.11 43.90 44.52 46.71 50.47 55.72 74.21 97.80 123.47 145.18 160.22 176.31];
%plot(year,num,'o')
lognum=log(num);
year1=year-1984;
loglognum=log(lognum);
%plot(year1,num)
fit=polyfit(year1,loglognum,14);
loglognum1=polyval(fit,year1);
%num1-loglognum
%plot(year1,loglognum,'ro',year1,loglognum1,'b*')
num1=exp(exp(loglognum1));
plot(year,num,'ro',year,num1,'b*')

进行了两次log运算 相当于是 num=e^e^(f(year-1984)) 这种形式的结果,f是多项式 fit是多项式系数,降幂排列

从图像上看还挺符合的

祝君好运哈