%fan - f_analog: sampling of the "analog" signal fan = 10; % Time singnal -- 1000 samples, 100 seconds t = 0:1/fan:100; t = t(1:end-1); % random signal repeating with period 200 samples xin = [rand*ones(1,50), rand*ones(1,50), rand*ones(1,50), rand*ones(1,50)]; xin = [xin xin xin xin xin]; % Noise and delay %% Very nice channel tau = 5; % delay, in seconds; peakNoise = 0.05; %% Delayed channel tau = 12; % delay, in seconds; peakNoise = 0.05; %% Noisy channel tau = 1; % delay, in seconds; peakNoise = 0.5; %% Very poor channel tau = 12; % delay, in seconds; peakNoise = 0.5; %% Perf %% Simulate and plot range = round([length(xin)-tau*fan:length(xin), 1:length(xin)-tau*fan]); xout = xin(range) + peakNoise*2*(rand(size(xin))-0.5); plot(t,xin,t,xout); % % filter noise % filtSize = 10; % boxFilt = 1/filtSize*ones(1,filtSize); % xfilt = filter(boxFilt,1,xout); % plot(t,xin,t,xfilt);