Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- clear all
- close all
- %INITIATION
- no_of_data_bits=64;
- M=4; %NO OF SUBCARRIERS
- n=256; %NO OF BITS TO BE TRANSMITTED AT TRANSMITTER
- block_size=16; %OFDM BLOCK FOR CYCLIC PREFIX
- cp_len=floor(0.1*block_size);
- %TRANSMITTER (TO GENERATE RANDOM DATA SOURCE)
- data=randsrc(1,no_of_data_bits,0:M-1);
- figure(1),
- stem(data);
- grid on;
- xlabel('Data points');
- ylabel('amplitude');
- title('original data');
- %PERFORM QPSK MODULATION
- qpsk_modulated_data=pskmod(data,M);
- figure(2),
- stem(qpsk_modulated_data);
- title('QPSK Modulation');
- S2P=reshape(qpsk_modulated_data,no_of_data_bits/M,M);
- sub_carrier1=S2P( :,1);
- sub_carrier2=S2P( :,2);
- sub_carrier3=S2P( :,3);
- sub_carrier4=S2P( :,4);
- figure(3),subplot(4,1,1),stem(sub_carrier1),title('Sub Carrier 1'),grid on;
- subplot(4,1,2),stem(sub_carrier2),title('Sub Carrier 2'),grid on;
- subplot(4,1,3),stem(sub_carrier3),title('Sub Carrier 3'),grid on;
- subplot(4,1,4),stem(sub_carrier4),title('Sub Carrier 4'),grid on;
- %IFFT OF 4 SUBCARRIERS
- M=4; %NO OF SUBCARRIERS
- cp_start=block_size-cp_len;
- ifft_subcarrier1 = ifft(sub_carrier1);
- ifft_subcarrier2 = ifft(sub_carrier2);
- ifft_subcarrier3 = ifft(sub_carrier3);
- ifft_subcarrier4 = ifft(sub_carrier4);
- figure(4),subplot(4,1,1),plot(real(ifft_subcarrier1),'r'),
- title('IFFT ON ALL THE SUBCARRIERS')
- subplot(4,1,2),plot(real(ifft_subcarrier2),'c')
- subplot(4,1,3),plot(real(ifft_subcarrier3),'b')
- subplot(4,1,4),plot(real(ifft_subcarrier4),'d')
- %ADD CYCLIC PREFIX
- for i=1:M
- ifft_subcarrier (:,i) = ifft(S2P(:,i),16);
- for j=1:cp_len
- cyclic_prefix(j,i) = ifft_subcarrier (j+cp_start,i);
- end
- Append_prefix(:,i) = vertcat(cyclic_prefix(:,i),ifft_subcarrier(:,i));
- end
- A1=Append_prefix(:,1);
- A2=Append_prefix(:,2);
- A3=Append_prefix(:,3);
- A3=Append_prefix(:,4);
- %Appends prefix to each subcarrier
- A1=Append_prefix(:,1);
- A2=Append_prefix(:,2);
- A3=Append_prefix(:,3);
- A4=Append_prefix(:,4);
- figure(5),subplot(5,1,1),plot(real(A1),'r'),
- title('CYCLIC PREFIX ADDED')
- subplot(5,1,2),plot(real(ifft_subcarrier2),'c')
- subplot(5,1,3),plot(real(ifft_subcarrier3),'b')
- subplot(5,1,4),plot(real(ifft_subcarrier4),'d')
- figure(6),plot(real(A2),'r'),
- title('ORTHOGONALITY'),hold on
- plot(real(A2),'c'),hold on
- plot(real(A3),'b'),hold on
- plot(real(A4),'d'),hold on
- grid on;
- %CONVERT SERIAL STREAM FOR TRANSMISSION
- [row_Append_prefix cols_Append_prefix]=size(Append_prefix);
- len_ofdm_data=row_Append_prefix*cols_Append_prefix;
- ofdm_signal=reshape(Append_prefix,1,len_ofdm_data);
- figure(7),
- plot(real(ofdm_signal));
- xlabel('TIME');
- ylabel('AMPLITUDE');
- title('OFDM SIGNAL');
- grid on;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement