xbit2num.m

来自「其中提到遺傳學的程式碼與應用提供給次淚相向的研究者參考下載」· M 代码 · 共 16 行

M
16
字号
function num = xbit2num(bit, range)% BIT2NUM Conversion from bit string representations to decimal numbers.%	BIT2NUM(BIT, RANGE) converts a bit string representation BIT ( a 0-1%	vector) to a decimal number, where RANGE is a two-element vector%	specifying the range of the converted decimal number.%%	For example:%%	bit2num([1 1 0 1], [0, 15])%	bit2num([0 1 1 0 0 0 1], [0, 127])%	Roger Jang, 12-24-94integer = polyval(bit, 2);      % x=2, [1 1 0 1]==> 1*2^3+1*2^2+0*2+1num = integer*((range(2)-range(1))/(2^length(bit)-1)) + range(1);  % Formula is correct

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?