Sie sind auf Seite 1von 9

Nama

NRP
Kelas

: Farah Adiba
: 1210131035
: 2 D4 Teknik Telekomunikasi B

Syntax :
% am.m
% Matlab demonstration script for DSB-AM modulation. The message signal
% is +1 for 0 < t < t0/3, -2 for t0/3 < t < 2t0/3 and zero otherwise.
close all;
echo on
t0=.15;
% signal duration
ts=0.001;
% sampling interval
fc=250;
% carrier frequency
fr=260;
% carrier frequency
snr=10;
% SNR in dB (logarithmic)
a=0.85;
% Modulation index
fs=1/ts;
% sampling frequency
t=[0:ts:t0];
% time vector
df=0.2;
% required frequency resolution
snr_lin=10^(snr/10);
% SNR
% message signal
m=[ones(1,t0/(3*ts)),-2*ones(1,t0/(3*ts)),zeros(1,t0/(3*ts)+1)];
c=cos(2*pi*fc.*t);
% carrier signal
c=cos(2*pi*fr.*t+pi/4);
% carrier signal
m_n=m/max(abs(m));
% normalized message signal
[M,m,df1]=fftseq(m,ts,df);
% Fourier transform
M=M/fs;
% scaling
f=[0:df1:df1*(length(m)-1)]-fs/2;
% frequency vector
u=(1+a*m_n).*c;
% modulated signal
[U,u,df1]=fftseq(u,ts,df);
% Fourier transform
U=U/fs;
% scaling
signal_power=spower(u(1:length(t)));
% power in modulated signal
% power in normalized message
pmn=spower(m(1:length(t)))/(max(abs(m)))^2;
eta=(a^2*pmn)/(1+a^2*pmn);
% modulation efficiency
noise_power=eta*signal_power/snr_lin;
% noise power
noise_std=sqrt(noise_power);
% noise standard deviation
noise=noise_std*randn(1,length(u));
% generate noise
r=u+noise;
% add noise to the modulated signal
[R,r,df1]=fftseq(r,ts,df);
% Fourier transform
R=R/fs;
% scaling
pause % Press a key to show the modulated signal power
signal_power
pause % Press a key to show the modulation efficiency
eta
pause % Press any key to see a plot of the message
figure(1);
subplot(2,2,1)
plot(t,m(1:length(t)))
axis([0 0.15 -2.1 2.1])
xlabel('Time')
title('The message signal')
pause
pause % Press any key to see a plot of the carrier

subplot(2,2,2)
plot(t,c(1:length(t)))
axis([0 0.15 -2.1 2.1])
xlabel('Time')
title('The carrier')
pause % Press any key to see a plot of the modulated signal
subplot(2,2,3)
plot(t,u(1:length(t)))
axis([0 0.15 -2.1 2.1])
xlabel('Time')
title('The modulated signal')
pause
% Press any key to see a plots of the magnitude of the message and
the
% modulated signal in the frequency domain.
figure(2);
subplot(2,1,1)
plot(f,abs(fftshift(M)))
xlabel('Frequency')
title('Spectrum of the message signal')
subplot(2,1,2)
plot(f,abs(fftshift(U)))
title('Spectrum of the modulated signal')
xlabel('Frequency')
pause % Press a key to see a noise sample
figure(3);
subplot(2,1,1)
plot(t,noise(1:length(t)))
title('noise sample')
xlabel('Time')
pause % Press a key to see the modulated signal and noise
subplot(2,1,2)
plot(t,r(1:length(t)))
title('Signal and noise')
xlabel('Time')
pause % Press a key to see the modulated signal and noise in freq. domain
figure(4);
subplot(2,1,1)
plot(f,abs(fftshift(U)))
title('Signal spectrum')
xlabel('Frequency')
subplot(2,1,2)
plot(f,abs(fftshift(R)))
title('Signal and noise spectrum')
xlabel('Frequency')
% dsb_dem.m
% Matlab demonstration script for DSB-AM demodulation. The message signal
% is +1 for 0 < t < t0/3, -2 for t0/3 < t < 2t0/3 and zero otherwise.\
close all;
echo on
t0=.15;
% signal duration
ts=1/1500;
% sampling interval
fc=250;
% carrier frequency
fr=260;
% carrier frequency
fs=1/ts;
% sampling frequency
t=[0:ts:t0];
% time vector
df=0.3;
% desired frequency resolution

m=[ones(1,t0/(3*ts)),-2*ones(1,t0/(3*ts)),zeros(1,t0/(3*ts)+1)];
%
message signal
c=cos(2*pi*fc.*t);
% carrier signal
cr=cos(2*pi*fc.*t+pi/4);
% carrier signal
u=m.*c;
% modulated signal
y=u.*cr;
% mixing
[M,m,df1]=fftseq(m,ts,df);
% Fourier transform
M=M/fs;
% scaling
[U,u,df1]=fftseq(u,ts,df);
% Fourier transform
U=U/fs;
% scaling
[Y,y,df1]=fftseq(y,ts,df);
% Fourier transform
Y=Y/fs;
% scaling
f_cutoff=150;
% cutoff freq. of the filter
n_cutoff=floor(150/df1);
% design the filter
f=[0:df1:df1*(length(y)-1)]-fs/2;
H=zeros(size(f));
H(1:n_cutoff)=2*ones(1,n_cutoff);
H(length(f)-n_cutoff+1:length(f))=2*ones(1,n_cutoff);
DEM=H.*Y;
% spectrum of the filter output
dem=real(ifft(DEM))*fs;
% filter output
pause % Press a key to see the effect of mixing
clf
subplot(3,1,1)
plot(f,fftshift(abs(M)))
title('Spectrum of the the Message Signal')
xlabel('Frequency')
subplot(3,1,2)
plot(f,fftshift(abs(U)))
title('Spectrum of the Modulated Signal')
xlabel('Frequency')
subplot(3,1,3)
plot(f,fftshift(abs(Y)))
title('Spectrum of the Mixer Output')
xlabel('Frequency')
pause % Press a key to see the effect of filtering on the mixer output
clf
subplot(3,1,1)
plot(f,fftshift(abs(Y)))
title('Spectrum of the Mixer Output')
xlabel('Frequency')
subplot(3,1,2)
plot(f,fftshift(abs(H)))
title('Lowpass Filter Characteristics')
xlabel('Frequency')
subplot(3,1,3)
plot(f,fftshift(abs(DEM)))
title('Spectrum of the Demodulator output')
xlabel('Frequency')
pause % Press a key to compare the spectra of the message an the received
signal
clf
subplot(2,1,1)
plot(f,fftshift(abs(M)))
title('Spectrum of the Message Signal')
xlabel('Frequency')
subplot(2,1,2)
plot(f,fftshift(abs(DEM)))

title('Spectrum of the Demodulator Output')


xlabel('Frequency')
pause
subplot(2,1,2)
plot(t,m(1:length(t)))
axis([0 0.15 -2.1 2.1])
xlabel('Time')
title('The message signal')
hold on
subplot(2,1,2)
plot(t,dem(1:length(t)),'m')
title('The Demodulator Output')
axis([0 0.15 -2.1 2.1])
xlabel('Time')
far=dem(1:length(t));
save far;
far1=m(1:length(t));
save far1;

Gambar gelombang input dan gelombang output yang di plot dalam satu grafik
yang sama

Data titik dari semua titik grafik gelombang input dan gelombang
output :

No
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

=
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

= /4
0.4678
0.5842
0.6706
0.7229
0.7442
0.7429
0.7295
0.7136
0.7016
0.6961
0.6963
0.6996
0.7034
0.7059
0.7070

DEVIASI
0.5322
0.4158
0.3294
0.2771
0.2558
0.2571
0.2705
0.2864
0.2984
0.3039
0.3037
0.3004
0.2966
0.2941
0.2930

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

0.7075
0.7086
0.7106
0.7128
0.7140
0.7129
0.7091
0.7034
0.6979
0.6951
0.6966
0.7027
0.7114
0.7195
0.7237
0.7217
0.7136
0.7021
0.6915
0.6861
0.6885
0.6986
0.7130
0.7263
0.7331
0.7301
0.7177
0.7000
0.6837
0.6753
0.6789
0.6941
0.7158
0.7360
0.7464
0.7420
0.7230
0.6958
0.6704
0.6572
0.6629
0.6873
0.7228
0.7562
0.7737
0.7659
0.7322
0.6825

0.2925
0.2914
0.2894
0.2872
0.2860
0.2871
0.2909
0.2966
0.3021
0.3049
0.3034
0.2973
0.2886
0.2805
0.2763
0.2783
0.2864
0.2979
0.3085
0.3139
0.3115
0.3014
0.2870
0.2737
0.2669
0.2699
0.2823
0.3000
0.3163
0.3247
0.3211
0.3059
0.2842
0.2640
0.2536
0.2580
0.2770
0.3042
0.3296
0.3428
0.3371
0.3127
0.2772
0.2438
0.2263
0.2341
0.2678
0.3175

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

1
1
1
1
1
1
1
1
1
1
1
1
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2

0.6346
0.6090
0.6213
0.6749
0.7573
0.8407
0.8876
0.8603
0.7310
0.4910
0.1545
-0.2433
-0.6534
-1.0244
-1.3139
-1.4983
-1.5762
-1.5669
-1.5037
-1.4238
-1.3589
-1.3278
-1.3342
-1.3685
-1.4136
-1.4517
-1.4704
-1.4660
-1.4434
-1.4133
-1.3874
-1.3745
-1.3777
-1.3937
-1.4152
-1.4338
-1.4431
-1.4409
-1.4293
-1.4136
-1.4001
-1.3933
-1.3948
-1.4031
-1.4142
-1.4238
-1.4286
-1.4277

0.3654
0.3910
0.3787
0.3251
0.2427
0.1593
0.1124
0.1397
0.2690
0.5090
0.8455
1.2433
-1.3466
-0.9756
-0.6861
-0.5017
-0.4238
-0.4331
-0.4963
-0.5762
-0.6411
-0.6722
-0.6658
-0.6315
-0.5864
-0.5483
-0.5296
-0.5340
-0.5566
-0.5867
-0.6126
-0.6255
-0.6223
-0.6063
-0.5848
-0.5662
-0.5569
-0.5591
-0.5707
-0.5864
-0.5999
-0.6067
-0.6052
-0.5969
-0.5858
-0.5762
-0.5714
-0.5723

112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159

-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
-2
0
0
0
0
0
0
0
0
0

-1.4222
-1.4150
-1.4088
-1.4057
-1.4061
-1.4089
-1.4126
-1.4154
-1.4168
-1.4170
-1.4169
-1.4171
-1.4178
-1.4182
-1.4173
-1.4143
-1.4095
-1.4046
-1.4019
-1.4038
-1.4109
-1.4219
-1.4328
-1.4387
-1.4353
-1.4215
-1.4005
-1.3795
-1.3680
-1.3744
-1.4018
-1.4450
-1.4901
-1.5160
-1.4995
-1.4214
-1.2728
-1.0587
-0.7988
-0.5237
-0.2684
-0.0642
0.0688
0.1258
0.1180
0.0680
0.0037
-0.0495

-0.5778
-0.5850
-0.5912
-0.5943
-0.5939
-0.5911
-0.5874
-0.5846
-0.5832
-0.5830
-0.5831
-0.5829
-0.5822
-0.5818
-0.5827
-0.5857
-0.5905
-0.5954
-0.5981
-0.5962
-0.5891
-0.5781
-0.5672
-0.5613
-0.5647
-0.5785
-0.5995
-0.6205
-0.6320
-0.6256
-0.5982
-0.5550
-0.5099
-0.4840
-0.5005
-0.5786
-0.7272
-0.9413
-1.2012
0.5237
0.2684
0.0642
-0.0688
-0.1258
-0.1180
-0.0680
-0.0037
0.0495

160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

-0.0753
-0.0694
-0.0388
0.0023
0.0376
0.0552
0.0506
0.0277
-0.0034
-0.0306
-0.0443
-0.0406
-0.0220
0.0035
0.0261
0.0375
0.0343
0.0184
-0.0034
-0.0228
-0.0327
-0.0299
-0.0160
0.0032
0.0204
0.0292
0.0267
0.0142
-0.0031
-0.0185
-0.0265
-0.0242
-0.0129
0.0029
0.0170
0.0243
0.0222
0.0118
-0.0027
-0.0158
-0.0225
-0.0205
-0.0109
0.0026
0.0147
0.0210
0.0192
0.0102

0.0753
0.0694
0.0388
-0.0023
-0.0376
-0.0552
-0.0506
-0.0277
0.0034
0.0306
0.0443
0.0406
0.0220
-0.0035
-0.0261
-0.0375
-0.0343
-0.0184
0.0034
0.0228
0.0327
0.0299
0.0160
-0.0032
-0.0204
-0.0292
-0.0267
-0.0142
0.0031
0.0185
0.0265
0.0242
0.0129
-0.0029
-0.0170
-0.0243
-0.0222
-0.0118
0.0027
0.0158
0.0225
0.0205
0.0109
-0.0026
-0.0147
-0.0210
-0.0192
-0.0102

208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

-0.0024
-0.0138
-0.0197
-0.0180
-0.0095
0.0023
0.0130
0.0185
0.0169
0.0090
-0.0022
-0.0123
-0.0175
-0.0160
-0.0085
0.0021
0.0117
0.0167
0.0153

0.0024
0.0138
0.0197
0.0180
0.0095
-0.0023
-0.0130
-0.0185
-0.0169
-0.0090
0.0022
0.0123
0.0175
0.0160
0.0085
-0.0021
-0.0117
-0.0167
-0.0153

>> sum (far,2)


ans =
-53.4758
>> sum(far,2)/226
ans =
-0.2366
Dari perhitungan melalui aplikasi matlab di atas,kita mendapatkan bahwa nilai
deviasinya :
%deviasi = (sum(far,2)/226) x 100 %
= -0.2366 x 100 %
= -23.66 %
Jadi,nilai dari deviasi kedua gelombang,yaitu gelombang 1 dengan (phase) = pi
dan gelombang 2 dengan (phase) = pi/4 adalah -23.66 %

Das könnte Ihnen auch gefallen