2

行ごとに 1 つのキーがある BEpos や BEneg などのキーを使用してスパース mlf にアクセスしようとしています。ここでの問題は、ほとんどのコマンドが大きすぎる入力を処理することを意図していないことです: bin2dec はスペースのないきれいな 2 進数を必要としますが、正規表現のハックは行数が多すぎると失敗します。

スパース キーを使用してスパース データにアクセスするにはどうすればよいですか?

K>>  mlf=sparse([],[],[],2^31,1);  
BEpos=Cg(pos,:)

BEpos =

   (1,1)        1
   (2,3)        1
   (2,4)        1

K>> mlf(bin2dec(num2str(BEpos)))=1
Error using bin2dec (line 36)
Binary string must be 52 bits or less.

K>> num2str(BEpos)

ans =

1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  1  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0

K>> bin2dec(num2str('1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0'))
Error using bin2dec (line 36)
Binary string must be 52 bits or less.

K>> regexprep(num2str(BEpos),'[^\w'']','')
Error using regexprep
The 'STRING' input must be a one-dimensional array
of char or cell arrays of strings.

手動で動作

K>> mlf(bin2dec('1000000000000000000000000000000'))

ans =

   All zero sparse: 1-by-1
4

2 に答える 2

0

これでインデックスを作成してみてください:

inds = uint32( bin2dec(cellstr(num2str(BEpos,'%d'))) );
于 2013-10-28T06:45:40.280 に答える