Series to parallel

by

 

fast with one for loop series to parallel

series2parallel(x,N)
function y = series2parallel(x,N)
%---------------
% series2parallel(x,N)
% x = informatin bits -array-
% N = number of subcarriers
% splits the array bits into number of parallel bits depending on the
% number of subcarriers
%---------------
L=length(x);                           %length of the information array
c=ceil(L/N);                           %number of columns

if rem(L,c) > 0                       %if there is a remainder
    x(c*N) = 0;                        %add zeros to complete info. matrix 
end

% for i=1:c                             %create the new matrix
%     newvector(1:N,i)=x((1+(i-1)*N):i*N);
% end
% y = newvector;
% m = [];
% for i = 1:N
%     m = [m ;x((1+(i-1)*c):i*c)]
% end   
% y = m;
%--another trial
% for j = 1:c
%     for i = 1:N
%         y(i,j) = x(N*(j-1)+i);
%     end
% end
%--final 
for j = 1:c
    y(1:N,j) = x(((j-1)*N) + 1 : (j*N));
end

Contact us