请问matlab高手们这个问题怎么改?谢谢!
k=11X0=[99.40101.21101.51100.00101.98104.72102.63102.29105.62106.72100.11;5.925.855.8...
k=11
X0=[99.40 101.21 101.51 100.00 101.98 104.72 102.63 102.29 105.62 106.72 100.11;
5.92 5.85 5.85 5.498 5.31 5.445 5.58 5.985 7.95 6.498 5.454;
34.78 36.22 37.66 39.09 40.53 41.73 42.99 43.9 44.4 44.9 45.63;
2701.31 3760.07 4021.47 4003.61 4018.87 3261.80 3205.01 3336.97 3507.52 3627.25 3058.85];
[n,m]=size(X0);
for j=1:m c=0;
for i=1:n
c=X0(i,j)+c;
X1(i,j)=c
end
end
%计算数据矩阵L
for j=1:m
for i=1:n-1
L(i,j)=(X1(i,j)+X1(i+1,j))/2;
end
end
B=[L ones(n-1,1)]
%计算Y 及参数估计值
for j=1:m
Y(1:n-1,j)=X0(2:n,j);
a(:,j)=inv(B'*B)*B'*Y(1:n-1,j);
end
a=a'
A=a(1:end,1:end-1)
B=a(1:end,end)
%计算模型的拟合值或预测值
S=X1(1,1:end)
if k==1
Z=S'
elseif k>1
Z=expmdemo2(A*(k-1))*S'+inv(A)*(expmdemo2(A*(k-1))-eye(size(expmdemo2(A*(k-1)))))*B-expmdemo2(A*(k-2))*S'-inv(A)*(expmdemo2(A*(k-2))-eye(size(expmdemo2(A*(k-2)))))*B
else disp(' 输入错误!k不得小于1')
end
错误提示是:??? Error using ==> horzcat
CAT arguments dimensions are not consistent.
Error in ==> GM1_N at 25
B=[L ones(1,n-1)] 展开
X0=[99.40 101.21 101.51 100.00 101.98 104.72 102.63 102.29 105.62 106.72 100.11;
5.92 5.85 5.85 5.498 5.31 5.445 5.58 5.985 7.95 6.498 5.454;
34.78 36.22 37.66 39.09 40.53 41.73 42.99 43.9 44.4 44.9 45.63;
2701.31 3760.07 4021.47 4003.61 4018.87 3261.80 3205.01 3336.97 3507.52 3627.25 3058.85];
[n,m]=size(X0);
for j=1:m c=0;
for i=1:n
c=X0(i,j)+c;
X1(i,j)=c
end
end
%计算数据矩阵L
for j=1:m
for i=1:n-1
L(i,j)=(X1(i,j)+X1(i+1,j))/2;
end
end
B=[L ones(n-1,1)]
%计算Y 及参数估计值
for j=1:m
Y(1:n-1,j)=X0(2:n,j);
a(:,j)=inv(B'*B)*B'*Y(1:n-1,j);
end
a=a'
A=a(1:end,1:end-1)
B=a(1:end,end)
%计算模型的拟合值或预测值
S=X1(1,1:end)
if k==1
Z=S'
elseif k>1
Z=expmdemo2(A*(k-1))*S'+inv(A)*(expmdemo2(A*(k-1))-eye(size(expmdemo2(A*(k-1)))))*B-expmdemo2(A*(k-2))*S'-inv(A)*(expmdemo2(A*(k-2))-eye(size(expmdemo2(A*(k-2)))))*B
else disp(' 输入错误!k不得小于1')
end
错误提示是:??? Error using ==> horzcat
CAT arguments dimensions are not consistent.
Error in ==> GM1_N at 25
B=[L ones(1,n-1)] 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询