-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcarrierAggr.m
199 lines (180 loc) · 4.72 KB
/
carrierAggr.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
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
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
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
clc
close all
clear all
% Basic Carrier Aggregation for simple OFDM transmit chain
%OFDM 2048 point
%The available bandwidth is 8 MHz
%Input Parameters-1
Tu=224e-6; %useful OFDM symbol period
T=Tu/2048; %baseband elementary period
G=0; %choice of 1/4, 1/8, 1/16, and 1/32
delta=G*Tu; %guard band duration
Ts=delta+Tu; %total OFDM symbol period
Kmax=1705; %number of subcarriers
Kmin=0;
FS=4096; %IFFT/FFT length
q=10; %carrier period to elementary period ratio
fc=q*1/T; %carrier frequency
Rs=4*fc; %simulation period
t=0:1/Rs:Tu;
%Data generator-1 (A)
M=Kmax+1;
rand('state',0);
a=-1+2*round(rand(M,1)).'+i*(-1+2*round(rand(M,1))).';
A=length(a);
info=zeros(FS,1);
info(1:(A/2)) = [ a(1:(A/2)).']; %Zero padding
info((FS-((A/2)-1)):FS) = [ a(((A/2)+1):A).'];
%Subcarriers generation (B)
carriers=FS.*ifft(info,FS);
tt=0:T/2:Tu;
figure(1);
subplot(211);
stem(tt(1:20),real(carriers(1:20)));
subplot(212);
stem(tt(1:20),imag(carriers(1:20)));
figure(2);
f=(2/T)*(1:(FS))/(FS);
subplot(211);
plot(f,abs(fft(carriers,FS))/FS);
subplot(212);
pwelch(carriers,[],[],[],2/T);
% D/A simulation-1(A)
L = length(carriers);
chips = [ carriers.';zeros((2*q)-1,L)];
p=1/Rs:1/Rs:T/2;
g=ones(length(p),1); %pulse shape
figure(3);
stem(p,g);
dummy=conv(g,chips(:));
u=[dummy(1:length(t))]; % (C)
figure(4);
subplot(211);
plot(t(1:400),real(u(1:400)));
subplot(212);
plot(t(1:400),imag(u(1:400)));
figure(5);
ff=(Rs)*(1:(q*FS))/(q*FS);
subplot(211);
plot(ff,abs(fft(u,q*FS))/FS);
subplot(212);
pwelch(u,[],[],[],Rs);
[b,a] = butter(13,1/20); %reconstruction filter
[H,F] = freqz(b,a,FS,Rs);
%[H,F] = FREQZ(b,a,FS,Rs);
figure(6);
plot(F,20*log10(abs(H)));
uoft = filter(b,a,u); %baseband signal (D)
figure(7);
subplot(211);
plot(t(80:480),real(uoft(80:480)));
subplot(212);
plot(t(80:480),imag(uoft(80:480)));
figure(8);
subplot(211);
plot(ff,abs(fft(uoft,q*FS))/FS);
subplot(212);
pwelch(uoft,[],[],[],Rs);
%Upconverter-1(A) to 91MHz
s_tilde=(uoft.').*exp(1i*2*pi*fc*t);
s=real(s_tilde); %passband signal (E)
figure(9);
plot(t(80:480),s(80:480));
figure(10);
subplot(211);
%plot(ff,abs(fft(((real(uoft).').*cos(2*pi*fc*t)),q*FS))/FS);
%plot(ff,abs(fft(((imag(uoft).').*sin(2*pi*fc*t)),q*FS))/FS);
plot(ff,abs(fft(s,q*FS))/FS);
subplot(212);
%hold on;
%pwelch(((real(uoft).').*cos(2*pi*fc*t)),[],[],[],Rs);
%pwelch(((imag(uoft).').*sin(2*pi*fc*t)),[],[],[],Rs);
pwelch(s,[],[],[],Rs);
% Input parameters-2(B)
Tu1=200e-6; %useful OFDM symbol period
T1=Tu1/2048; %baseband elementary period
G1=0; %choice of 1/4, 1/8, 1/16, and 1/32
delta1=G1*Tu1; %guard band duration
Ts1=delta1+Tu1; %total OFDM symbol period
Kmax1=1705; %number of subcarriers
Kmin1=0;
FS1=4096; %IFFT/FFT length
q1=10; %carrier period to elementary period ratio
fc1=q1*1/T1; %carrier frequency
Rs1=4*fc1; %simulation period
t1=0:1/Rs1:Tu1;
%Data generator-2 (B)
M1=Kmax1+1;
rand('state',0);
a1=-1+2*round(rand(M1,1)).'+i*(-1+2*round(rand(M1,1))).';
A1=length(a1);
info=zeros(FS1,1);
info(1:(A1/2)) = [ a1(1:(A1/2)).']; %Zero padding
info((FS1-((A1/2)-1)):FS1) = [ a1(((A1/2)+1):A1).'];
%Subcarriers generation (B)
carriers1=FS1.*ifft(info,FS1);
tt1=0:T1/2:Tu1;
figure(11);
subplot(211);
stem(tt1(1:20),real(carriers1(1:20)));
subplot(212);
stem(tt1(1:20),imag(carriers1(1:20)));
figure(12);
f1=(2/T1)*(1:(FS1))/(FS1);
subplot(211);
plot(f1,abs(fft(carriers1,FS1))/FS1);
subplot(212);
pwelch(carriers1,[],[],[],2/T1);
% D/A simulation-2 (B)
L1 = length(carriers1);
chips1 = [ carriers1.';zeros((2*q1)-1,L1)];
p1=1/Rs1:1/Rs1:T1/2;
g1=ones(length(p1),1); %pulse shape
figure(13);
stem(p1,g1);
dummy1=conv(g1,chips(:));
u1=[dummy1(1:length(t1))]; % (C)
figure(14);
subplot(211);
plot(t1(1:400),real(u1(1:400)));
subplot(212);
plot(t1(1:400),imag(u1(1:400)));
figure(15);
ff1=(Rs1)*(1:(q1*FS1))/(q*FS1);
subplot(211);
plot(ff1,abs(fft(u1,q1*FS1))/FS1);
subplot(212);
pwelch(u1,[],[],[],Rs1);
[b1,a1] = butter(13,1/20); %reconstruction filter
[H1,F1] = freqz(b1,a1,FS1,Rs1);
%[H,F] = FREQZ(b,a,FS,Rs);
figure(16);
plot(F1,20*log10(abs(H1)));
uoft1 = filter(b1,a1,u1); %baseband signal (D)
figure(17);
subplot(211);
plot(t1(80:480),real(uoft1(80:480)));
subplot(212);
plot(t1(80:480),imag(uoft1(80:480)));
figure(18);
subplot(211);
plot(ff1,abs(fft(uoft1,q1*FS1))/FS1);
subplot(212);
pwelch(uoft1,[],[],[],Rs1);
%Upconverter-2 (B) to about 110 MHz
s_tilde1=(uoft1.').*exp(1i*2*pi*fc1*t1);
s1=real(s_tilde1); %passband signal (E)
figure(19);
plot(t1(80:480),s1(80:480));
figure(20);
subplot(211);
%plot(ff,abs(fft(((real(uoft).').*cos(2*pi*fc*t)),q*FS))/FS);
%plot(ff,abs(fft(((imag(uoft).').*sin(2*pi*fc*t)),q*FS))/FS);
%hold on
plot(ff1,abs(fft(s1,q1*FS1))/FS1);
subplot(212);
%pwelch(((real(uoft).').*cos(2*pi*fc*t)),[],[],[],Rs);
%pwelch(((imag(uoft).').*sin(2*pi*fc*t)),[],[],[],Rs);
pwelch(s1,[],[],[],Rs1);
figure(21);
pwelch(s,[],[],[],Rs)+pwelch(s1,[],[],[],Rs1);