%EXP

clear all;
close all;
clc;
delete *.jpg;

set(0,'DefaultFigureWindowStyle','docked');
warning('off','all');
warning;

fi = 1;
options.font = 'Times';
options.font_size = 18;
options.line_w = 2;
options.line_w1 = 3;
options.marker = 'ox+*d<>';
options.markersize = 12;
options.markersize1 = 12;
options.col = 'krbmgcy';
options.db_scale = -25;

% ff = 'D:\2021\21_project\pipebots\matlab\sparse array imaging\';
% ffs = 'D:\2021\21_project\pipebots\matlab\sparse array imaging\results\';

ff = [];
ffs = [];

fs1 = 'Results_sim_da_ML_05_Ns6_rs6';
fs2 = 'Results_sim_da_ML_1_Ns6_rs6';
fs3 = 'Results_sim_da_ML_15_Ns6_rs6';
fs4 = 'Results_sim_da_ML_2_Ns6_rs6';

fs5 = 'Results_sim_da_ML_05_Ns8_rs6';
fs6 = 'Results_sim_da_ML_1_Ns8_rs6';
fs7 = 'Results_sim_da_ML_15_Ns8_rs6';
fs8 = 'Results_sim_da_ML_2_Ns8_rs6';

fs9 = 'Results_sim_da_ML_05_Ns10_rs6';
fs10 = 'Results_sim_da_ML_1_Ns10_rs6';
fs11 = 'Results_sim_da_ML_15_Ns10_rs6';
fs12 = 'Results_sim_da_ML_2_Ns10_rs6';

options.font = 'Times';
options.font_size = 18;
options.line_w = 2;
options.line_w1 = 3;
options.marker = 12;
options.marker1 = 12;
options.col = 'krbmgcy';
options.db_scale = -20;


for jj = 1 : 3
    tmps1 = [];
    for ii = 1 : 4
        kk = ii + (jj - 1) * 4;
        %%%----sim da
        eval(['fs = fs',num2str(kk),';']);
        fname = [ffs fs];
        load(fname);
        tmps = Results_sim.amp_a;
        
        tmp_kk = find(sqrt(Results_sim.x_da.^2 + Results_sim.z_da.^2) <= Results_sim.options.rm);
        
        tmps1 = [tmps1;tmps(1,tmp_kk)];
        tmps2 = tmps(2:end,tmp_kk);
        
        simda_m(jj,ii + 1) = mean(tmps2(:));
        simda_std(jj,ii + 1) = std(tmps2(:));        
    end
    simda_m(jj,1) = mean(tmps1(:));
    simda_std(jj,1) = std(tmps1(:));
end

num_e = 0:0.5:2;
 
figure(fi);fi = fi + 1;
for jj = 1 : 3
    hold on;plot(num_e,simda_m(jj,:),['-' options.col(jj) 'x'],'LineWidth',options.line_w,'MarkerSize',options.marker);
end
xlabel('{\it\sigma_p} ({\it\lambda})');
ylabel('{\it\mu_e} ({\it\lambda})');
% title('max location error (\lambda)');
% colorbar;
set(gca,'FontName',options.font,'FontSize',options.font_size);
box on;
legend('N_s = 6','N_s = 8','N_s = 10');
saveas(gcf,['tmp',num2str(fi),'.jpg']);

figure(fi);fi = fi + 1;
for jj = 1 : 3
    hold on;plot(num_e,simda_std(jj,:),['-' options.col(jj) 'x'],'LineWidth',options.line_w,'MarkerSize',options.marker);
end
xlabel('{\it\sigma_p} ({\it\lambda})');
ylabel('{\it\sigma_e} ({\it\lambda})');
% title('max location error (\lambda)');
% colorbar;
set(gca,'FontName',options.font,'FontSize',options.font_size);
box on;
% legend('N_s = 6','N_s = 8','N_s = 10');
saveas(gcf,['tmp',num2str(fi),'.jpg']);