function [b2] = make_noisy (b,a,w) % Takes a clean 0-1 barcode signal b and noises it up. % Constants. multiplier = 8; % how much longer to make the barcode % Resample barcode at more points. [temp,N] = size(b); b1 = zeros(temp,multiplier*N); for i = 1:N b1(1+(i-1)*multiplier:i*multiplier) = b(i); end; % Convolve with Gaussian. [temp,N] = size(b1); if mod(N,2) == 1 b1 = [b1 0]; end; [temp,N] = size(b1); %shift = round(N/2); %g = a .* exp (- ( ([1:N]-shift)/w).^2); %h = conv(b1,g); x = [1:N]./N - 0.5; g = a.* exp( - (x/w).^2); h = conv(b1,g); h = h(N/2+1:3*N/2); noise = max(h) / 6; % Add noise. [M,N] = size(h); b2 = h + (2*noise) .* (rand([M,N]) - 0.5);