大神可以帮忙看下吗,这里nz只有等于2时才可以运行,换成其他matlab就显示.*处错误,Matrix dimensions must agree.实在看不出哪里错了这里rawdata是一个957x5的矩阵。
data = rawdata(1:900,:);
nz =1;
T = rows(data)-nz;
R = data(1+nz:T+nz,1:2);
neq=2;
re=data(1+nz:T+nz,3);
r=abs(re);
p=data(1+nz:T+nz,4);
n=data(1+nz:T+nz,5);
Y = ones(T,neq);
X = R;
Z = ones(T,1);
for i = 1:nz
Z = [Z rawdata(1+nz-i:T+nz-i,1:2)];
end
b=[1;10;1;1];
gmmopt.infoz.momt='leanygmm';
gmmopt.plot=0;
gmmopt.gmmit=10;
out=gmm(b,gmmopt,Y,X,Z);
function [m,e]=leanygmm(b,infoz,stat,Y,X,Z)
global r;
global p;
global n;
[T, neq] = size(Y);
k = cols(Z);
north = neq*k;
R=X;
imrs =b(1)/b(2)*p.*(r.^(b(1)-1))+b(3)*b(4)/b(2)*n.*(r.^(b(4)-1));
e = repmat(imrs,1,neq).*R - Y;
m = reshape(Z'*e/T,north,1);
已解决,谢谢