OutputPort1=InputPort1;
OutputPort2=InputPort2;



mu=2; % QAM modulation index
m=2^mu; % QAM modulation number
K=128;  % subcarrier number
M=4;  % time slot number
CP_rate=1/4;  %
b_length=mu*K*M;  %length of data block
size_over=b_length;
N=K;  %upsample rate (N  must >= K)
ifft_length=N*M;  % fft length
alpha=0.1;



D1=reshape(InputPort1.Sampled.Signal,[K,M]); % get data block D
D2=reshape(InputPort2.Sampled.Signal,[K,M]); % get data block D

%%% Upsampling
s=zeros(ifft_length,M); % s will be a sampling matrix
for ii=1:ifft_length
    for jj=1:M
        if ii==(jj-1)*N+1
            s(ii,jj)=1;
        end
    end
end


%%% Pulse shaping 

filter_h=rcosdesign(alpha,M,N);
filter_h=filter_h(1:length(filter_h)-1); % filter_h is the coefficient of the filter
filter_column=filter_h';
G_Tx=circulant(filter_column,1);

gtx=G_Tx*s;

% %%%%%%%%%%%%%%%fft%%%%%%%%%%%%%%%%%%%%
Nn = 0:1:M*K-1; % row vector for n
Kk = 0:1:K-1; % ro0w vecor for k
WN = exp(-1i*2*pi/(N)); % Twiddle factor (w)
kn = Kk'*Nn; % creates a N by N matrix of nk values
WNnk1 = (WN .^ kn); % FFT matrix

wh1=WNnk1'; % IFFT matrix

A=zeros(M*K);

for i= 1:M*K
%     for j=1:M*K 
    A(i,:)= kron(wh1(i,:),gtx(i,:));  
%     end
end

d1=reshape(D1,M*K,1);
d2=reshape(D2,M*K,1);


% d{k}=D{k}(:);
x_trans1=A*d1;
x_trans2=A*d2;
x_trans1=x_trans1.';
x_trans2=x_trans2.';
OutputPort1.Sampled.Signal=x_trans1;
OutputPort2.Sampled.Signal=x_trans2;
