function [prior1, transmat1, mu1, Sigma1, mixmat1] = treningMGP(data, broj_trening_podataka, Mix, States)
%mixture gaussian sa pozicijama + broj prstiju

O = 3; %length of vector
T = 36; %length of vector sequence, broj frammeova
nex = broj_trening_podataka; %number of vector sequences, za treniranje, koliko opazanja
% data = randn(O,T,nex);
podatci=data;

%podatak
for i = 1:nex
    for j=1:36
        for k= 1:3
%             if i == 100 
%                 podataktocan(k,j)=podatci{i}(j,k);
%                 if k==3 && podataktocan(k,j)==0
%                     podataktocan(k,j)=20;
%                 end
%                 if k==3 && podataktocan(k,j)>5
%                     podataktocan(k,j)=5;
%                 end
%             elseif i == 22
%                 podatakkrivi(k,j)=podatci{i}(j,k);
%                 if k==3 && podatakkrivi(k,j)==0
%                     podatakkrivi(k,j)=20;
%                 end
%                 if k==3 && podatakkrivi(k,j)>5
%                     podatakkrivi(k,j)=5;
%                 end
%             else
                podatak(k,j,i)=podatci{i}(j,k);
                
                if k==3 && podatak(k,j)>5
                    podatak(k,j)=5;

                end
                if k==3 && podatak(k,j)==0
                    podatak(k,j)=6;
                end
%                 end
        end
    end
end

M =Mix; %mixture of 2 gaussians
Q = States;  %the number of states
left_right = 1;

prior0 = normalise(rand(Q,1));
transmat0 = mk_stochastic(rand(Q,Q));

[mu0, Sigma0] = mixgauss_init(Q*M, reshape(podatak, [O T*nex]), 'diag');
mu0 = reshape(mu0, [O Q M]);
Sigma0 = reshape(Sigma0, [O O Q M]);
mixmat0 = mk_stochastic(rand(Q,M));


%poboljsavanje matrica

[LL, prior1, transmat1, mu1, Sigma1, mixmat1] = mhmm_em(podatak, prior0, transmat0, mu0, Sigma0, mixmat0, 'max_iter', 7);
%MGPnex100diagLR1(M,Q)=LL(end);


%testiranje sa nizom

%logliktocan = mhmm_logprob(podataktocan, prior1, transmat1, mu1, Sigma1, mixmat1);
%loglikkrivi = mhmm_logprob(podatakkrivi, prior1, transmat1, mu1, Sigma1, mixmat1);
end