In: Electrical Engineering
Generate a signal composed of two square waves, the first has a 14 Hz and the second has a 55 Hz frequency. Both waves are sampled at 2 kHz for 200 ms. Duty cycle for the first wave is 40% while the second’s is 35%. Show the signal with and without adding white Gaussian noise with a variance of 1/100 in matlab
Hello,
Please find
the answer attached as under. Please give a thumbs up
rating if you find the answer useful! Have a rocking day
ahead!
****** Matlab Code *******
Fs =
2e3;
% sampling freq
t =
0:1/Fs:(200e-3);
% time base
f1 =
14;
% frequencies of the pulses
f2 = 55;
pulsewidth1 =
(40/100)*(1/f1);
% ON periods
pulsewidth2 = (35/100)*(1/f2);
pulseperiods1 =
[0:Fs*200e-3]*(1/f1);
% time periods
pulseperiods2 = [0:Fs*200e-3]*(1/f2);
x1 = pulstran(t,pulseperiods1,@rectpuls,pulsewidth1);
x2 = pulstran(t,pulseperiods2,@rectpuls,pulsewidth2);
subplot(2,1,1);
plot(t,x1+x2);
xlabel('Time (s)');
title('Pulse without noise');
var = 1/100;
y = x1+x2+sqrt(var)*randn(size(t));
subplot(2,1,2);
plot(t,y);
xlabel('Time (s)');
title('Pulse with noise');
********* Output *********