clear; bits = 64; threshold = 0.5; %Generate 64 random values. Check help on rand() function. data = rand(1, bits); %Quantize the random values only between two levels; 0 and 1. for i=1:length(data) if data (i) > threshold data2(i) = 1; else data2(i) = 0; end end %Commands for plotting the data. subplot(5, 1, 1); stairs(data2) title('Original Digital Data'); ylabel('Amplitute'); axis([0 bits -0.2 1.2]); grid off; %%%%%%%%%%%%%%%Genrate Gaussian Noise%%%%%%%%%%%%%%%%%%%%%% %%Different values for standard deviation for noise sn = 0.12:0.3:1.8; for i=1:length(sn) %%Generare different noise vectors. noise1 = randn(1, bits)*sn(i); %%Add noise to original data; recv_x = data2+noise1; %%Note the figures. As the noise level increases the data becomes increasingly corrupted. subplot(5, 1, i+1); stairs(recv_x) title('Received data mixed with noise'); ylabel('Amplitute'); axis([0 bits -2 2]); for i=1:length(recv_x) if recv_x(i) > threshold recv_data(i) = 1; else recv_data(i) = 0; end end end