I get this error message when running the code, 'Output argument "a" (and maybe others) not assigned during call to…MH'. But 'a' is exactly in the output from function MH, plus, if I run the codes for each j, it works fine, only when I run the loop, this error message comes out. Where do I get wrong?
for i=2:N x = xdraw(i-1, :); for j = 1:5 new = normrnd(x(j), sigma(j)); [x a] = MH(x,j,new,y,sigma); acc_x(j)=acc_x(j)+a; end xdraw(i, :) = x; end
Best Answer