一段matlab程序,不知道哪里不对,

问题描述:

一段matlab程序,不知道哪里不对,
t=[1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010];
x=[566 632 745 755 769 789 985 1110 1313 1428 1782 1920 2150 2292 2601 3149 4338 5145 5809 6241 6854 7656 8772 10007 11374 12567 14332 16614 19228 22844 26404 29688 32074];
myfunc=inline('(566*beta(1))/(566*beta(2)+(beta(1)-566*beta(2))*exp(-beta(1)*(t-1978)))','beta','t');
beta=nlinfit(t,x,myfunc,[0 0]);
a=beta(1),b=beta(2)
%test the model
tt=min(X):max(x);
xx=(a-2*b*x)*(a-b*x)*x
plot(t,x,‘0‘,t,xx,'r')
显示?Error using ==> nlinfit at 113
Error evaluating inline model function.
Caused by:
Error using ==> inlineeval at 15
Error in inline expression ==> (566*beta(1))/(566*beta(2)+(beta(1)-566*beta(2))*exp(-beta(1)*(t-1978)))
Matrix dimensions must agree.
1个回答 分类:综合 2014-11-09

问题解答:

我来补答
(566*beta(1))/(566*beta(2)+(beta(1)-566*beta(2))*exp(-beta(1)*(t-1978)))
这个表达式中数据的维数不对称,566*beta(1)应该是一个数吧,但是t却是一个数组,一个数除以一个数组怎么运算?
如果是数据元素分别运算,那么应该用./和.*运算,而不是/和*
再问: wuwu
 
 
展开全文阅读
剩余:2000
上一页:周五
下一页:责任的事实论据