%% carrega dados
load('Exp3.mat')

%% media por linha (de cada video)
mean_Ann = mean(Ann,2);

%% desvio padrao por linha (de cada video)
std_Ann = std(Ann,0,2);
% desvio padrao em percentagem
std_perc = (std_Ann ./ mean_Ann) * 100;
% organiza os valores em ordem crescente
std_perc_Sort = sort(std_perc,'ascend');

%% desvio padrao medio
std_mean = nanmean(std_Ann,1);
std_mean_line = ones(size(std_Ann)) * std_mean;

%% desvio padrao relativo medio
std_relat = nanmean(std_perc,1);
std_relat_line = ones(size(std_Ann)) * std_relat;

%% Grafico
figure(1)
hold on
grid on
plot(std_perc_Sort,'b.')
plot(std_Ann,'gx')
plot(std_relat_line,'r-')
plot(std_mean_line,'k-')
legend('STD(%)','STD','STD\_Relative\_Mean','STD\_Mean','Location','West')

for v = 1 : size(Ann,1)
    for p = 1 : size(Ann,2)
        dif_mean(v,p) = Ann(v,p) - mean_Ann(v);
    end
end

%% media por linha (de cada video)
mean_difMean = mean(dif_mean,2);

%% desvio padrao por linha (de cada video)
std_difMean = std(mean_difMean,0,2);
% desvio padrao em percentagem
std_difPerc = (std_difMean ./ mean_difMean) * 100;
% organiza os valores em ordem crescente
std_difPerc_Sort = sort(std_difPerc,'ascend');

%% desvio padrao medio
std_difMean = nanmean(std_difMean,1);
std_difMean_line = ones(size(std_difMean)) * mean_difMean;

%% desvio padrao relativo medio
std_difRelat = nanmean(std_difPerc,1);
std_difRelat_line = ones(size(std_difMean)) * std_difRelat;

%% Grafico
figure(2)
hold on
grid on
plot(std_difperc_Sort,'b.')
plot(std_difMean,'gx')
plot(std_difRelat_line,'r-')
plot(std_difMean_line,'k-')
legend('STD(%)','STD','STD\_Relative\_Mean','STD\_Mean','Location','West')
