524 Practical MATLAB® Applications for Engineers
0 0.5
−1.5
− 1
−0.5
0
0.5
Amplitude
1
1.5
2
1 1.5 2
Time
2.5 3 3.5
× 10 −^3
4
[noise+0.3*sin(2*pi*1000*t)+0.93*cos(2*pi*200*t)+0.69*sin(2*pi*3000*t)] versus t
Communication signal = information + noise
FIGURE 5.37
Plot of signal(t) = noise + f(t) of Example 5.8.
signal _ n = noise+0.7*sin(2*pi*1000*t)+0.93*cos(2*pi*2000*t)+0.69*sin
(2*pi*3000*t);
figure(1)
plot (t(1:33),signal _ n(1:33))
title(‘[noise+0.3*sin(2*pi*1000*t)+0.93*cos(2*pi*2000*t)+0.69*sin(2*pi*
3000*t)] vs t’)
xlabel(‘time’); ylabel(‘Amplitude’);
figure(2)
DFT _ mag = abs(fft(signal _ n,256));
DFT _ phase = angle(fft(signal _ n,256));
subplot (2,1,1)
DFTX = DFT _ mag(1:1:128);
W = [1:1:N/2].*fs/N;
plot (W,DFTX); title(‘DFT Magnitude and Phase’)
ylabel (‘Magnitude’);xlabel(‘frequency in Hertz’)
subplot (2,1,2)
DFTY= DFT _ phase(1:1:128);
W = [1:1:N/2].*fs/N;
plot (W,DFTY);xlabel(‘frequency in Hertz’); ylabel (‘Angle’)
The script fi le signal_n is executed and the results are indicated in the Figures 5.37
and 5.38.