clear all; close all; clc

load('SIGS.mat');

sn=4;
b=zeros(size(SIGS,2), size(SIGS,3));
sigs=[];
for s=1:sn
    b(:,:) = SIGS(s,:,:);
    sigs = [sigs; b'];
end;


pocet_features = 23;
fs = 10e7;
thr_level_mV = 700;
t = linspace(0,1,2000);
pocet_signalu = 128;
l = [-3, -6, -10, -20, -30, -40, -50]; 
[k,m] = size(l);
res = zeros(m,pocet_features,pocet_signalu);
q = ['db3    '; 'db10   '; 'db8    '; 'db9    '; 'db5    '; 'db7    ';  'sym4   '; 'sym6   '; 'sym8   '; 'coif1  '; 'coif3  '; 'coif5  '; 'bior2.2'; 'bior2.4'; 'bior2.8'; 'bior3.5'; 'bior3.9'; 'dmey   '];
[w,e] = size(q);
noise_x = zeros(m*pocet_signalu,2000);
denoise_x = zeros(m,2000,pocet_signalu);
sig = pocet_signalu - 1;
vysledky = ones(m,4);
vysledky2 = ones(7*w,4);

for o = 1:w %pouzita vlnka
 for j = 1:m
    for i = 1:pocet_signalu          
x = sigs(i,:);    
noise_signal = awgn(x,l(:,j)); % zasumení signálu

[thr,sorh,keepapp] = ddencmp('den','wv',noise_signal); % zakladní parametry pro redukci sumu
xd = wdencmp('gbl',noise_signal,q(o,:),4,thr,sorh,keepapp);  % redukce sumu

res(j,:,i) = identify_signal_features(xd, fs, thr_level_mV); % definice parametrů AE
     
    end;
      res2(:,:) = res(j,:,:);
features_o = res2';
metoda_normalizace_hodnot = 'var';

POPIS_SHLUKOVE_ANALYZY = 'Vsechny features';
[koeficient_rozlisitelnosti{1}, metody] = shlukova_analyza_umele_zdrojeAE(features_o, metoda_normalizace_hodnot, POPIS_SHLUKOVE_ANALYZY);

koef = koeficient_rozlisitelnosti{1,1};
vysledky(j,:) = koef;
end;
vysledky2((j*o)-6:j*o,:) = vysledky;
end;

