[問題] 挑掉負值已回收
1 1 1 0 -1 -1 -1 -1 -1 -1
0 1 0 1 -1 -1 -1 -1 -1 -1
0 0 1 0 -1 -1 -1 -1 -1 -1
1 1 0 1 -1 -1 -1 -1 -1 -1
1 1 0 1 -1 -1 -1 -1 -1 -1
0 1 1 0 -1 -1 -1 -1 -1 -1
0 0 1 0 -1 -1 -1 -1 -1 -1
0 1 1 0 -1 -1 -1 -1 -1 -1
0 1 1 1 -1 -1 -1 -1 -1 -1
1 1 1 0 -1 -1 -1 -1 -1 -1
想請教各位因為我有一行式子在加總每一列ex y=sum(x)---->x是上面的東西
一列一列的加,但是我現在有負號的東西不想加進去不知道可不可以?
因為我這個負號不一定會在最後面有可能會在任何地方?以下是我的程式!想破頭啦
x的範圍是0.5到1 bits=[lengh lengh lengh lengh] lengh=10 vub=1 vlb=0.5
function [gen,lchrom,coarse,nround] = encode1(x,vlb,vub,bits)
lchrom = sum(bits);
coarse = (vub-vlb)./((2.^bits)-1);
[x_row,x_col] = size(x);
gen = [];
if ~isempty(x),
temp = (x-ones(x_row,1)*vlb)./ ...
(ones(x_row,1)*coarse)
b10 = round(temp);
% Since temp and b10 should contain integers 1e-4 is close enough
nround = find(b10-temp>1e-4);
gen = b10to2(b10,bits);
end
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.192.240.157
→
10/13 00:42, , 1F
10/13 00:42, 1F
→
10/13 07:48, , 2F
10/13 07:48, 2F
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章