-2
は、私は、まさにこのエラーを得た:Matlabの2013aインデックスエラー
Attempted to access E(3,1); index must be a positive integer or logical.
しかし、インデックスがE(3,1)
あり、これらの数字はいずれも正です。何が起こっている? E(3,1)
で
for t=T:0.2:4
for i=1:N
% D = D +1
x = randi(Nsamples,1,1);
if(x==1)
Etemp = E(t*5,i) - S(x)*S(x+1) + (-S(x))*S(x+1);
elseif(x==Nsamples)
Etemp = E(t*5,i) - S(x)*S(x-1) + (-S(x))*S(x-1);
else
%********************* This is the error line
Etemp = E(t*5,i) - (S(x-1)*S(x)+S(x)*S(x+1))+ (S(x-1)*(-S(x))+(-S(x))*S(x+1));
end
end
end
't * 5'は整数ではありません。浮動小数点です。参照:[なぜ24.0000はMATLABの24.0000と等しくないのですか?](http://stackoverflow.com/questions/686439/why-is-24-0000-not-equal-to-24-0000-in-matlab) – excaza
なぜt * 5 = 3(E(3,1))のときだけエラーが発生するのですか?値が2のときではなく(E(2,1))? – Bekromoularo
それは偶然です。 – excaza