Code covered by the BSD License  

Highlights from
Random Signal generation

image thumbnail

Random Signal generation

by

 

A compilation of random signal generation scripts that can be used for Testing various algorithms

s=BoolNoise(a,noise_factor,width_factor)
function s=BoolNoise(a,noise_factor,width_factor)
% BoolNoise    -  Function to inject noise in any Boolean Signal.
% a            -  Input boolean signal. Can either be a 1 column array with
%                 boolean data or 2 columns with first column as time and
%                 second column data. (As generated by GenRandomBool)
% noise_factor -  [0 to 1 ] A control factor that controls the amount of
%                 boolean noise to be added to signal 'a'. Use values between
%                 0.1 and 0.5 for best results.
% width_factor -  [0 to 1 ] A control factor that controls the width of the
%                 perturbations noise added to the boolean signal 'a'. Use
%                 values between 0.1 to 0.5 for best results.
%
% Copyright Srivalli G S - srivalli047@gmail.com
% Nov 2013

x=a(:,end);
index1=randperm(length(a))';
index=index1(1:round(noise_factor/0.1));
for j=1:(length(index))
    z(j) =((index(j)+((width_factor/0.1)*10)));
    if(z(j)>length(x))
        z(j)=length(x);
    end
    if(index(j) > length(x))
        index(j) =length(x);
    end
    if(j>length(index))
        for i=1:(length(index)-1)
            if(index(i+1) <= z(j))
                index(i+1)=index(i)+(((width_factor/0.1)*10)+1);
            end
        end
    end
    x(index(j):z(j))=not(x(index(j)));
end
if size(a,2)>1
    s= [a(:,1) x];
else
    s=x;
end
end




Contact us