%%%%%%%%%% Cyclic Prefix %%%%%%%%%%
%%%%%%%%%% SURAJ BASTOLA %%%%%%%%%%
M = 8; % for 8 BPSK
N = 64;% this means we are using 64 point FFT/IFFT
data = randi(M,1,N)-1;
subplot(411);
myplot(stem(data),'Data',3);
X = pskmod(data,M);
figure(2);
subplot(111);
myplot(plot(X,'o'),'8PSK',2);
% IFFT with real result for Baseband
% for broad band go directly to line 17 from 10 with code x = ifft(X, N);
X1 = X;
X2 = conj(X(N:-1:2));
X1(1) = real(X(1));
X = [X1, imag(X(1)), X2];
x = ifft(X, N*2);
figure(1)
subplot(412);
myplot(plot(1:128,x),'IFFT', 1);
% add circular prefix
delay = 10;
xt = [x(2*N-delay+1:2*N),x];
subplot(413);
myplot(plot(1:(2*N+delay),xt),'CP',2);
hold on
myplot(plot(1+delay:(2*N+delay),x),'OFDM',1);
% remove Cyclic Prefix
r = xt((1+delay):(2*N+delay));
%fft
r2 = fft(r,N*2);
% undo complex number modification
r3 = r2(1:N);
r3(1) = r2(1)+1i*r2(N+1);
data2 = pskdemod(r3,M);
subplot(414);
myplot(stem(data2),'Received',4);
disp([data;data2]);
No comments:
Post a Comment