我有一个 1000x1 数组,我希望它根据 lambda 值 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