2

私は1000x1の配列を持っており、ラムダ値lam_packetに基づいて等しい部分に分割し、各部分で0 0 0 0をラドムのバイナリ値に置き換えますが、この関数を呼び出すと、エラー

??? Error using ==> bsxfun
Non-singleton dimensions of the two input arrays must match each other.

Error in ==> imputation at 11
idx = bsxfun(@plus, idx', (0:3));

どんな助けでも大歓迎です。

function [ xxx ] = imputation(x,lam_packet,noframes)
x1=x(:,1:-1:1).';
for i=1:lam_packet:noframes
%# starting locations of four-consecutive zeros
idx= strfind(x1(i), [0 0 0 0]);

%# random binary numbers (rows) used to replace the consecutive zeros
n = dec2bin(randi([0 8],[numel(idx) 1]),4) - '0';

%# linear indices corresponding to the consecutive-zeros
idx = bsxfun(@plus, idx', (0:3));

%'# replace the 4-zeros
xx = x1;
xx(idx(:)) = n(:);
end
xxx = xx(1:-1:1,:).';

end
enter code here
4

1 に答える 1

0

idxは、すべての[0 000]文字列の場所を返す「strfind」呼び出しの結果です。したがって、これは任意のサイズの配列であり、配列のサイズは「x1」の内容によって異なります。したがって、おそらく長さ4ではありません。bsxfunへの他の入力は長さ4であるため、エラーが発生します。

于 2011-11-25T15:22:16.790 に答える