filenames  = dir ("*.csv");

for x=1:length(filenames)
    
    eval(['ridic_' filenames(x).name(1:3) ' = ridici_v3("' filenames(x).name '");'])
    
end
for x=1:length(filenames)
   
     eval([ 'rozmer_abs(x)= length(ridic_' filenames(x).name(1:3) '.int_krit.abs);'])
     
end
 [max_delka,max_delka_idx] = max(rozmer_abs);

out_matice = nan(max_delka*length(filenames),6); %vznik matice pro ukladani
out_ridici = ones(max_delka*length(filenames),1);
cisla_ridicu = who('ridic_*');
cisla_ridicu = cell2mat(cisla_ridicu);
cisla_ridicu(:,1:6) = [];
cisla_ridicu = str2num(cisla_ridicu);

%%  ukladani kriterii do matice
for k=1:length(filenames)
    start_idx = (k-1)*max_delka+1; % sum(rozmer_abs(1:k-1))+1 
    stop_idx = (k-1)*max_delka+max_delka; % sum(rozmer_abs(1:k-1)) + rozmer_abs(k) 
    eval (['out_matice(start_idx:length(ridic_' filenames(k).name(1:3) '.int_krit.abs)+start_idx-1,1) = ridic_' filenames(k).name(1:3) '.int_krit.abs;']) 
    eval (['out_matice(start_idx:length(ridic_' filenames(k).name(1:3) '.int_krit.kvadr)+start_idx-1,2) = ridic_' filenames(k).name(1:3) '.int_krit.kvadr;']) 
    eval (['out_matice(start_idx:length(ridic_' filenames(k).name(1:3) '.int_krit.ITAE)+start_idx-1,3) = ridic_' filenames(k).name(1:3) '.int_krit.ITAE;']) 
    eval (['out_matice(start_idx:length(ridic_' filenames(k).name(1:3) '.reactTime)+start_idx-1,4) = ridic_' filenames(k).name(1:3) '.reactTime;']) 
    eval (['out_matice(start_idx:length(ridic_' filenames(k).name(1:3) '.riseTime)+start_idx-1,5) = ridic_' filenames(k).name(1:3) '.riseTime;']) 
    eval (['out_matice(start_idx:length(ridic_' filenames(k).name(1:3) '.OverShootTime)+start_idx-1,6) = ridic_' filenames(k).name(1:3) '.OverShootTime;'])
    eval (['out_matice(start_idx:length(ridic_' filenames(k).name(1:3) '.Gain)+start_idx-1,7) = ridic_' filenames(k).name(1:3) '.Gain;'])
    eval (['out_matice(start_idx:length(ridic_' filenames(k).name(1:3) '.T)+start_idx-1,8) = ridic_' filenames(k).name(1:3) '.T;'])
    eval (['out_matice(start_idx:length(ridic_' filenames(k).name(1:3) '.ksi)+start_idx-1,9) = ridic_' filenames(k).name(1:3) '.ksi;'])
    %   ukladani vystupu  
    out_ridici(start_idx:stop_idx) = cisla_ridicu(k);
    
end
% udelat matici 22x9x4 pro rozdeleni ridicu, pro srandu
%% ukoly
% gplotmatrix, color=lines(2); gplotmatrix(X,[],Y,color) 
 figure(2)
 subplot(231)
 histogram(ridic_074.reactTime)
 xlabel('Doba [s]')
 title('Reakční čas')
 subplot(232)
 histogram(ridic_074.riseTime)
 title('Doba náběhu')
 xlabel('Doba [s]')
 subplot(233)
 histogram(ridic_074.OverShootTime)
 title('Doba překmitu')
 xlabel('Doba [s]')
 subplot(234)
 histogram(ridic_074.int_krit.abs)
 title('Absolutní kritérium')
 xlabel('[s^2]')
 subplot(235)
 histogram(ridic_074.int_krit.kvadr)
 title('Kvadratické kritérium')
 xlabel('[s^3]')
 subplot(236)
 histogram(ridic_074.int_krit.ITAE)
 title('ITAE kritérium')
 xlabel('[s^3]')
 
 %% pomucky pro vykreslovaní
 % plot(ss_peaksW(:,1),WheelAngle(ss_peaksW(:,1)),'mx') , vyznacovani bodu
 % na krivce
 % funkce gca pro popisky os u grafu
