MATLAB问题 急求

来源:百度知道 编辑:UC知道 时间:2024/05/05 00:17:43
这段MATLAB程序我运行不出来,谁帮帮忙看看是哪有问题 谢谢

x_orig=[2951.1 3323.9 3939.2 4916.2 6656.4 8100.0 9080.0 9405.3 9296.5 9875.5 10656.2 11830.9 13161.1 14743.5 16900.2 19638.6] ;
%AGO process
x(i)=cumsum(x_orig(i));
%compute the coefficient(a and u)------------------------
n=length(x_orig);
%first generate the matrix B
for i=1:(n-1);
B(i)=-(x(i)+x(i+1))/2;
end
B=[B' ones(n-1,1)];
%then generate the matrix Y
for i=1:(n-1);
y(i)=x_orig(i+1);
end
Y=y';
%get the coefficient. a=au(1) u=au(2)
au=(inv(B'*B))*(B'*Y);
%--------------------------------------------------------
%change the grey model to symbolic expression
coef1=au(2)/au(1);
coef2=x_orig(1)-coef1;
coef3=0-au(1);
costr1=num2str(coef1);
costr2=num2str(abs(coef2));
costr3=num2str(coef3);
eq=strcat(costr1,'+',costr2,'e^',costr3,'*(t-1))');
%comparison of calculated and obse

只有两个小瑕疵:
x_orig=[2951.1 3323.9 3939.2 4916.2 6656.4 8100.0 9080.0 9405.3 9296.5 9875.5 10656.2 11830.9 13161.1 14743.5 16900.2 19638.6]%用半角的分号
%AGO process
x=cumsum(x_orig);%直接这样既可

全部程序:
clc;clear
x_orig=[2951.1 3323.9 3939.2 4916.2 6656.4 8100.0 9080.0 9405.3 9296.5 9875.5 10656.2 11830.9 13161.1 14743.5 16900.2 19638.6]%用半角的分号
%AGO process
x=cumsum(x_orig);%直接这样既可
%compute the coefficient(a and u)------------------------
n=length(x_orig);
%first generate the matrix B
for i=1:(n-1);
B(i)=-(x(i)+x(i+1))/2;
end
B=[B' ones(n-1,1)];
%then generate the matrix Y
for i=1:(n-1);
y(i)=x_orig(i+1);
end
Y=y';
%get the coefficient. a=au(1) u=au(2)
au=(inv(B'*B))*(B'*Y);
%--------------------------------------------------------
%change the grey model to symbolic expression
coef1=au(2)/au(1);
coef2=x_orig(1)-coef1;
coef3=0-au(1);
costr1