%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                        %
%                              LTE_Blok                                  %
%                                                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%vstupne premenne:
%data - data z prenosoveho kanala [double]
%blok - velkost bloku [int]
%rate - rate kodera [double]
%vystupna premenna:
%out - data rozdelene do blokov [double]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function out = LTE_Blok(data,blok,rate)

y = [];                                                                     
table = dlmread('LTE_table.txt');                                           %nacitanie hodnot povolenych blokov
[r, s] = find(table(:,1)==blok);

if (~isempty(r)&&~isempty(s))
    %%RATE 1/3
    if (rate == 1/3)                                                        
        b = blok*3;                                                         
        it = floor(length(data)/b);                                         
        for i = 1:it     
            y(i,:) = data(1,(i*b-b)+1:i*b);                                 %S P1 P2                               
        end
    %%RATE 1/2
    elseif (rate == 1/2)                                                                        
        b = blok*2;                                                         
        it = floor(length(data)/b);
        for i = 1:it
            y(i,:) = data(1,(i*b-b)+1:i*b);                                 %S P1 P2 - len polovice s par.
        end
    end
else
    error('Nespravna velkost bloku.');
end
out = y;                                                                    %vystup funkcie
end