私はMatlabで数値法を実装しています。しかし、私の数式に何か問題があるか、Matlab がばかげているようです。Matlabで1920を取得したいのですが、結果は次のとおりです。Pythonインタープリターが与える
>>> x0_square = 3200
>>> x0 = 2560
>>> scale_factor = 2048
>>> x = 2048
>>> a = x0_square + ( ( (2 * x0) * (x - x0) ) / scale_factor)
>>> print a
1920
しかし、Matlabは
% all variables here is int16. all value are the same as the above.
>> x_square_a = int16(x0_square + ( ( (2 .* x0) .* (x - x0) ) ./ scale_factor));
>> x_square_a
x_square_a =
3184
なぜ彼らは異なる結果を与えるのですか?Matlabインタープリターから1920を取得するにはどうすればよいですか? また、int16 以外の変数は使用できないという制約があります。