我有像这样的八度/ Matlab函数。
function [z] = baseline_als(y, lam, p, niter)
L = size(y);
D = sparse(diff(eye(L), 2));
w = ones(L);
for i = 1:niter
W = sparse.spdiags(w, 0, L, L); %error comes here
Z = W + lam * dot(D,transpose(D));
% z = spsolve(Z, w*y);
z= Z\(w*y);
w = p * (y > z) + (1-p) * (y < z);
end % End of For loop
end % End of function
我这样称呼(在其他文件中),
z = baseline_als(X,1000,0.00001,20)
plot(z)
其中X是1D向量。
我参考了here的文档。但无法弄清楚这个错误。我该如何解决这个问题?