function [Site,Site_ENG,FIG,FIG_ENG] = report_CrossGraphs(rTL,rIPL,rTuL,rRaL,...
    rPCL,rPL,rRL,rKL,rCrL,rMPBEL,GI_Disp_TL,GI_Date_TL,GI_Prof_TL,GI_Disp_IPL,...
    GI_Date_IPL,GI_Prof_IPL,GI_Level_PL,GI_Prof_PL,GI_Date_PL,GI_Rain_RL,GI_Date_RL,...
    GI_Angolo_KL,GI_Num_KL,GI_Date_KL,GI_Disp_CrL,GI_Num_CrL,GI_Date_CrL,GI_Q1_TuL,...
    GI_Q2_TuL,GI_Q3_TuL,GI_Q4_TuL,GI_Q1_Num_TuL,GI_Q2_Num_TuL,GI_Q3_Num_TuL,...
    GI_Q4_Num_TuL,GI_Z_TuL,GI_Seg_TuL,GI_NumSeg_TuL,GI_Date_TuL,GI_Z_PCL,GI_Date_PCL,...
    GI_XYZ_Rad,GI_Num_Rad,GI_dS_RL_MPB,GI_dS_RL_TuL,GI_dS_TuL_RL,GI_Date_Rad,...
    GI_Date_MPB,GI_dS_MPB,GI_MPB_Base,GI_dS_MPB_RL,siteID,toolrif,chainID,Font_Chapter,...
    Font_caption,Font_tools,m,rAR,br,FIG,FIG_ENG,DT,DT_ENG,activeEN,FileName)

fileID = fopen(FileName,'a');
fmt = '%s \r';
text = 'report_CrossGraphs function started';
fprintf(fileID,fmt,text);

import mlreportgen.dom.*
import mlreportgen.report.*

% Make sure DOM is compilable
makeDOMCompilable()

%% --- TILT LINK + PIEZO LINK ---
% Tilt Link V + Piezo Link : Spostamento massimo locale vs Falda
if rTL(m,1) > 0 && rPL(m,1) > 0 && exist( 'GI_Disp_TL','var')
    if isempty(GI_Level_PL(:,m)) == 0 && GI_Date_PL(1,m) ~= 0 && isempty(GI_Disp_TL(:,m)) == 0 && GI_Date_TL(1,m) ~= 0
        ind_PL = find(GI_Date_PL(:,m));
        ind_TL = find(GI_Date_TL(:,m));
        sezGrafTLvsPL = Paragraph('Correlazioni tra sensori - Tilt Link vs Piezo Link');
        sezGrafTLvsPL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
        GI_VarFaldaPL = GI_Level_PL(:,m)-GI_Level_PL(1,m);
        figure(21)
        yyaxis left
        GI_TiltLink = plot(GI_Date_TL(1:ind_TL(end),m),GI_Disp_TL(1:ind_TL(end),m),'Color','red');
        set(gca,'YColor','k')
        LIM = ylim;
        if max(GI_Disp_TL(:,m)) < 10
            ylim([-inf 10]);
        elseif 1-max(GI_Disp_TL(:,m))/LIM(1,2) < 0.2
            if max(GI_Disp_TL(:,m)) < 1
                newlim = LIM(1,2)+LIM(1,2)*0.3;
            else
                newlim = LIM(1,2)+LIM(1,2)*0.1;
            end
            ylim([-inf newlim]);
        end
        ylabel('Spostamento [mm]');
        yyaxis right
        GI_PiezoLink = plot(GI_Date_PL(1:ind_PL(end),m),GI_VarFaldaPL(1:ind_PL(end)),':','Color','blue');
        var = max(abs(GI_VarFaldaPL(1:ind_PL(end))));
        media = mean(GI_VarFaldaPL(1:ind_PL(end)));
        LIM = ylim;
        if var < 0.7
            ylim([media-0.5 media+0.5]);
        elseif 1-max(GI_VarFaldaPL(1:ind_PL(end)))/LIM(1,2) < 0.2
            if max(GI_VarFaldaPL(1:ind_PL(end))) < 1
                newlim = LIM(1,2)+LIM(1,2)*0.3;
            else
                newlim = LIM(1,2)+LIM(1,2)*0.1;
            end
            ylim([-inf newlim]);
        end
        ylabel('Variazione del livello idrico [m]');
        set(gca,'YColor','k')
        title('Correlazione spostamenti - variazioni di falda');
        xlabel('Data [gg/mm/aaaa]');
        h = gca;
        h.XAxis.MinorTick = 'on';
        datetick('x','dd/mm/yyyy','keepticks','keeplimits');
        xtickangle(20);        
        yyaxis left
        lgdTL = (['Spostamenti (' num2str(GI_Prof_TL(1,m)) ' m)']);
        lgdPL = ('Variazione Falda');
        str(1,1) = {['Spostamenti (' num2str(GI_Prof_TL(1,m)) ' m)']};
        str(2,1) = {'Variazione Falda'};
        lgd = legend(lgdTL,lgdPL, 'Location','north');
        numcolumns = 2;
        [legend_h,object_h,plot_h,text_strings] = columnlegend(numcolumns,str);
        clear str
        
        testoTLvsPL = Paragraph(['Il grafico seguente ha l''obiettivo di evidenziare '...
            'eventuali correlazioni presenti tra variazioni del livello di falda e '...
            'spostamenti registrati dai sensori di tipo inclinometrico. '...
            'In particolare, con riferimento al periodo temporale considerato, '...
            'vengono presi in considerazione il nodo che ha registrato '...
            'il maggior spostamento differenziale locale in direzione di massima pendenza '...
            'ed il piezometro che ha misurato una variazione di falda maggiore '...
            '(nel caso la catena presenti un singolo piezometro, i dati riportati sono riferiti '...
            'all''unico sensore disponibile).']);
        testoTLvsPL2 = Paragraph(['In questo caso, gli spostamenti riportati nel grafico '...
            'si riferiscono al sensore posizionato a ' num2str(GI_Prof_TL(1,m)) ' m di profondit' char(224) ', '...
            'mentre l''andamento della falda ' char(232) ' riferito alle misure del piezometro ' ...
            'collocato ad una profondit' char(224) ' di ' num2str((GI_Prof_PL(1,m))) ' metri.']);
        
        TempName = char(strcat('Report',siteID,'-', char(toolrif),'-TLvsPL.png'));
        saveas(GI_PiezoLink,TempName);
        ChartTLvsPL = Image(TempName);
        ChartTLvsPL.Style = {ScaleToFit};
        ChartTLvsPL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto tra i dati di massimo '...
            'spostamento differenziale locale in direzione di massima pendenza e variazione '...
            'del livello idrico nel periodo temporale di riferimento']);
        FIG = FIG+1;
        ChartTLvsPL_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
        testoTLvsPL.HAlign = 'justify';
        testoTLvsPL2.HAlign = 'justify';
        add(DT,sezGrafTLvsPL);
        add(DT,testoTLvsPL);
        add(DT,testoTLvsPL2);
        add(DT,ChartTLvsPL);
        add(DT,ChartTLvsPL_cap);
        add(DT,br);
        close(figure(21));
        
        %--ENG--
        if activeEN == 1
            sezGrafTLvsPL_ENG = Paragraph('Correlations between sensors - Tilt Link vs Piezo Link');
            sezGrafTLvsPL_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            GI_VarFaldaPL = GI_Level_PL(:,m)-GI_Level_PL(1,m);
            figure(22)
            yyaxis left
            GI_TiltLink = plot(GI_Date_TL(1:ind_TL(end),m),GI_Disp_TL(1:ind_TL(end),m),'Color','red');
            set(gca,'YColor','k')
            LIM = ylim;
            if max(GI_Disp_TL(:,m)) < 10
                ylim([-inf 10]);
            elseif 1-max(GI_Disp_TL(:,m))/LIM(1,2) < 0.2
                if max(GI_Disp_TL(:,m)) < 1
                    newlim = LIM(1,2)+LIM(1,2)*0.3;
                else
                    newlim = LIM(1,2)+LIM(1,2)*0.1;
                end
                ylim([-inf newlim]);
            end
            ylabel('Displacement [mm]');
            yyaxis right
            GI_PiezoLink = plot(GI_Date_PL(1:ind_PL(end),m),GI_VarFaldaPL(1:ind_PL(end)),':','Color','blue');
            var = max(abs(GI_VarFaldaPL(1:ind_PL(end))));
            media = mean(GI_VarFaldaPL(1:ind_PL(end)));
            LIM = ylim;
            if var < 0.7
                ylim([media-0.5 media+0.5]);
            elseif 1-max(GI_VarFaldaPL(1:ind_PL(end)))/LIM(1,2) < 0.2
                if max(GI_VarFaldaPL(1:ind_PL(end))) < 1
                    newlim = LIM(1,2)+LIM(1,2)*0.3;
                else
                    newlim = LIM(1,2)+LIM(1,2)*0.1;
                end
                ylim([-inf newlim]);
            end
            ylabel('Water level variation [m]');
            set(gca,'YColor','k')
            title('Correlation between displacements and water level variation');
            xlabel('Date [dd/mm/yyyy]');
            h = gca;
            h.XAxis.MinorTick = 'on';
            datetick('x','dd/mm/yyyy','keepticks','keeplimits');
            xtickangle(20);
            yyaxis left
            lgdTL = (['Displacements (' num2str(GI_Prof_TL(1,m)) ' m)']);
            lgdPL = ('Water level variation');
            str(1,1) = {['Displacements (' num2str(GI_Prof_TL(1,m)) ' m)']};
            str(2,1) = {'Water level variation'};
            lgd = legend(lgdTL,lgdPL, 'Location','north');
            numcolumns = 2;
            [legend_h,object_h,plot_h,text_strings] = columnlegend(numcolumns,str);
            clear str
            
            testoTLvsPL = Paragraph(['The following graph aims to highlight the presence of '...
                'correlations between displacement data and water level variations. '...
                'In particular, for what concern the reference time period, the comparison '...
                'will focus on the sensor that measured the maximum local differential '...
                'displacement and the piezometer that recorded the largest water level variation. '...
                'If the Array includes only one piezometer, the graph is going to include monitoring '...
                'data measured by the only sensor available.']);

            testoTLvsPL2 = Paragraph(['In this case, displacement data reported in the graph '...
                'refer to the sensor located at ' num2str(GI_Prof_TL(1,m)) ' m of depth, while '...
                'the represented water level variation derives from the piezometer installed ' ...
                'at ' num2str((GI_Prof_PL(1,m))) ' m of depth.']);
            
            TempName = char(strcat('Report',siteID,'-', char(toolrif),'-TLvsPL_ENG.png'));
            saveas(GI_PiezoLink,TempName);
            ChartTLvsPL_ENG = Image(TempName);
            ChartTLvsPL_ENG.Style = {ScaleToFit};
            ChartTLvsPL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between the '...
                'maximum local differential displacement and the water level variation '...
                'measured during the reference time period']);
            FIG_ENG = FIG_ENG+1;
            ChartTLvsPL_ENG_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
            testoTLvsPL.HAlign = 'justify';
            testoTLvsPL2.HAlign = 'justify';
            add(DT_ENG,sezGrafTLvsPL_ENG);
            add(DT_ENG,testoTLvsPL);
            add(DT_ENG,testoTLvsPL2);
            add(DT_ENG,ChartTLvsPL_ENG);
            add(DT_ENG,ChartTLvsPL_ENG_cap);
            add(DT_ENG,br);
            close(figure(22));
        end
        % pulisco variabili da riutilizzare per catena successiva
        clear GI_VarFaldaPL;
    end
end

%% --- IN PLACE LINK + PIEZO LINK ---
% In Place Link + Piezo Link : Spostamento massimo locale vs Falda
if rIPL(m,1) > 0 && rPL(m,1) > 0 && exist( 'GI_Disp_IPL','var')
    if isempty(GI_Level_PL(:,m)) == 0 && GI_Date_PL(1,m) ~= 0 && ...
            isempty(GI_Disp_IPL(:,m)) == 0 && GI_Date_IPL(1,m) ~= 0
        ind_PL = find(GI_Date_PL(:,m));
        ind_IPL = find(GI_Date_IPL(:,m));
        sezGrafIPLvsPL = Paragraph('Correlazioni tra sensori - In Place Link vs Piezo Link');
        sezGrafIPLvsPL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
        GI_VarFaldaPL = GI_Level_PL(:,m)-GI_Level_PL(1,m);
        figure(21)
        yyaxis left
        GI_InPlaceLink = plot(GI_Date_IPL(1:ind_IPL(end),m),GI_Disp_IPL(1:ind_IPL(end),m),'Color','red');
        set(gca,'YColor','k')
        LIM = ylim;
        if max(GI_Disp_IPL(:,m)) < 10
            ylim([-inf 10]);
        elseif 1-max(GI_Disp_IPL(:,m))/LIM(1,2) < 0.2
            if max(GI_Disp_IPL(:,m)) < 1
                newlim = LIM(1,2)+LIM(1,2)*0.3;
            else
                newlim = LIM(1,2)+LIM(1,2)*0.1;
            end
            ylim([-inf newlim]);
        end
        ylabel('Spostamento [mm]');
        yyaxis right
        GI_PiezoLink = plot(GI_Date_PL(1:ind_PL(end),m),GI_VarFaldaPL(1:ind_PL(end)),':','Color','blue');
        var = max(abs(GI_VarFaldaPL(1:ind_PL(end))));
        media = mean(GI_VarFaldaPL(1:ind_PL(end)));
        LIM = ylim;
        if var < 0.7
            ylim([media-0.5 media+0.5]);
        elseif 1-max(GI_VarFaldaPL(1:ind_PL(end)))/LIM(1,2) < 0.2
            if max(GI_VarFaldaPL(1:ind_PL(end))) < 1
                newlim = LIM(1,2)+LIM(1,2)*0.3;
            else
                newlim = LIM(1,2)+LIM(1,2)*0.1;
            end
            ylim([-inf newlim]);
        end
        ylabel('Variazione del livello idrico [m]');
        set(gca,'YColor','k')
        title('Correlazione spostamenti - variazioni di falda');
        xlabel('Data [gg/mm/aaaa]');
        h = gca;
        h.XAxis.MinorTick = 'on';
        datetick('x','dd/mm/yyyy','keepticks','keeplimits');
        xtickangle(20);
        lgdIPL = (['Spostamenti (' num2str(GI_Prof_IPL(1,m)) ' m)']);
        lgdPL = ('Variazione Falda');
        str(1,1) = {['Spostamenti (' num2str(GI_Prof_IPL(1,m)) ' m)']};
        str(2,1) = {'Variazione Falda'};
        lgd = legend(lgdIPL,lgdPL, 'Location','north');
        numcolumns = 2;
        [legend_h,object_h,plot_h,text_strings] = columnlegend(numcolumns,str);
        clear str
        
        testoIPLvsPL = Paragraph(['Il grafico seguente ha l''obiettivo di evidenziare '...
            'eventuali correlazioni presenti tra variazioni del livello di falda e '...
            'spostamenti registrati dai sensori di tipo inclinometrico. '...
            'In particolare, con riferimento al periodo temporale considerato, '...
            'vengono presi in considerazione il nodo che ha registrato '...
            'il maggior spostamento differenziale locale in direzione di massima pendenza '...
            'ed il piezometro che ha misurato una variazione di falda maggiore '...
            '(nel caso la catena presenti un singolo piezometro, i dati riportati sono riferiti '...
            'all''unico sensore disponibile).']);
        testoIPLvsPL2 = Paragraph(['In questo caso, gli spostamenti riportati nel grafico '...
            'si riferiscono al sensore posizionato a ' num2str(GI_Prof_IPL(1,m)) ...
            ' m di profondit' char(224) ', mentre l''andamento della falda ' ...
            char(232) ' riferito alle misure del piezometro collocato ad una '...
            'profondit' char(224) ' di ' num2str((GI_Prof_PL(1,m))) ' metri.']);
        
        TempName = char(strcat('Report',siteID,'-', char(toolrif),'-IPLvsPL.png'));
        saveas(GI_PiezoLink,TempName);
        ChartIPLvsPL = Image(TempName);
        ChartIPLvsPL.Style = {ScaleToFit};
        ChartIPLvsPL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto tra i dati di massimo '...
            'spostamento differenziale locale in direzione di massima pendenza e variazione '...
            'del livello idrico nel periodo temporale di riferimento']);
        FIG = FIG+1;
        ChartIPLvsPL_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
        testoIPLvsPL.HAlign = 'justify';
        testoIPLvsPL2.HAlign = 'justify';
        add(DT,sezGrafIPLvsPL);
        add(DT,testoIPLvsPL);
        add(DT,testoIPLvsPL2);
        add(DT,ChartIPLvsPL);
        add(DT,ChartIPLvsPL_cap);
        add(DT,br);
        close(figure(21));
        
        %--ENG--
        if activeEN == 1
            sezGrafIPLvsPL_ENG = Paragraph('Correlations between sensors - In Place Link vs Piezo Link');
            sezGrafIPLvsPL_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            GI_VarFaldaPL = GI_Level_PL(:,m)-GI_Level_PL(1,m);
            figure(22)
            yyaxis left
            GI_InPlaceLink = plot(GI_Date_IPL(1:ind_IPL(end),m),GI_Disp_IPL(1:ind_IPL(end),m),'Color','red');
            set(gca,'YColor','k')
            LIM = ylim;
            if max(GI_Disp_IPL(:,m)) < 10
                ylim([-inf 10]);
            elseif 1-max(GI_Disp_IPL(:,m))/LIM(1,2) < 0.2
                if max(GI_Disp_IPL(:,m)) < 1
                    newlim = LIM(1,2)+LIM(1,2)*0.3;
                else
                    newlim = LIM(1,2)+LIM(1,2)*0.1;
                end
                ylim([-inf newlim]);
            end
            ylabel('Displacement [mm]');
            yyaxis right
            GI_PiezoLink = plot(GI_Date_PL(1:ind_PL(end),m),GI_VarFaldaPL(1:ind_PL(end)),':','Color','blue');
            var = max(abs(GI_VarFaldaPL(1:ind_PL(end))));
            media = mean(GI_VarFaldaPL(1:ind_PL(end)));
            LIM = ylim;
            if var < 0.7
                ylim([media-0.5 media+0.5]);
            elseif 1-max(GI_VarFaldaPL(1:ind_PL(end)))/LIM(1,2) < 0.2
                if max(GI_VarFaldaPL(1:ind_PL(end))) < 1
                    newlim = LIM(1,2)+LIM(1,2)*0.3;
                else
                    newlim = LIM(1,2)+LIM(1,2)*0.1;
                end
                ylim([-inf newlim]);
            end
            ylabel('Water level variation [m]');
            set(gca,'YColor','k')
            title('Correlation between displacements and water level variation');
            xlabel('Date [dd/mm/yyyy]');
            h = gca;
            h.XAxis.MinorTick = 'on';
            datetick('x','dd/mm/yyyy','keepticks','keeplimits');
            xtickangle(20);
            lgdIPL = (['Displacements (' num2str(GI_Prof_IPL(1,m)) ' m)']);
            lgdPL = ('Water level variation');
            str(1,1) = {['Displacements (' num2str(GI_Prof_IPL(1,m)) ' m)']};
            str(2,1) = {'Water level variation'};
            lgd = legend(lgdIPL,lgdPL, 'Location','north');
            numcolumns = 2;
            [legend_h,object_h,plot_h,text_strings] = columnlegend(numcolumns,str);
            clear str
            
            testoIPLvsPL = Paragraph(['The following graph aims to highlight the presence of '...
                'correlations between displacement data and water level variations. '...
                'In particular, for what concern the reference time period, the comparison '...
                'will focus on the sensor that measured the maximum local differential '...
                'displacement and the piezometer that recorded the largest water level variation. '...
                'If the Array includes only one piezometer, the graph is going to include monitoring '...
                'data measured by the only sensor available.']);

            testoIPLvsPL2 = Paragraph(['In this case, displacement data reported in the graph '...
                'refer to the sensor located at ' num2str(GI_Prof_IPL(1,m)) ' m of depth, while '...
                'the represented water level variation derives from the piezometer installed ' ...
                'at ' num2str((GI_Prof_PL(1,m))) ' m of depth.']);
            
            TempName = char(strcat('Report',siteID,'-', char(toolrif),'-IPLvsPL_ENG.png'));
            saveas(GI_PiezoLink,TempName);
            ChartIPLvsPL_ENG = Image(TempName);
            ChartIPLvsPL_ENG.Style = {ScaleToFit};
            ChartIPLvsPL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between the '...
                'maximum local differential displacement and the water level variation '...
                'measured during the reference time period']);
            FIG_ENG = FIG_ENG+1;
            ChartIPLvsPL_ENG_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
            testoIPLvsPL.HAlign = 'justify';
            testoIPLvsPL2.HAlign = 'justify';
            add(DT_ENG,sezGrafIPLvsPL_ENG);
            add(DT_ENG,testoIPLvsPL);
            add(DT_ENG,testoIPLvsPL2);
            add(DT_ENG,ChartIPLvsPL_ENG);
            add(DT_ENG,ChartIPLvsPL_ENG_cap);
            add(DT_ENG,br);
            close(figure(22));
        end
        % pulisco variabili da riutilizzare per catena successiva
        clear GI_VarFaldaPL;
    end
end

Site = Chapter;
if activeEN == 1
    Site_ENG = Chapter;
else
    Site_ENG = [];
end
%% Grafici riassuntivi del SITO
if m == rAR && rAR > 1 
    titleCha = 0;
    % --- Piogge vs falda ---
    if sum(rRL) > 0 && sum(rPL) > 0 && exist('GI_Rain_RL','var') && exist('GI_Level_PL','var')
        if isempty(GI_Level_PL) == 0 && isempty(GI_Rain_RL) == 0
            if titleCha == 0
                sezSITE = Heading1('Correlazioni fra i diversi sensori presenti in sito');
                sezSITE.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                Site.Title = sezSITE;
                spazio = Paragraph('');
                add(Site,spazio);
                if activeEN == 1
                    sezSITE_ENG = Heading1('Correlations between different sensors installed on site');
                    sezSITE_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                    Site_ENG.Title = sezSITE_ENG;
                    spazio = Paragraph('');
                    add(Site_ENG,spazio);
                end
                titleCha = 1;
            end
            sezGrafRLvsPL = Heading2('Correlazioni tra sensori - Rain Link vs Piezo Link');
            sezGrafRLvsPL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            GI_VarFaldaPL = GI_Level_PL-GI_Level_PL(1,:);
            testoRLvsPL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                'evidenziare eventuali correlazioni presenti tra il piezometro '...
                'che ha registrato le maggiori variazioni di falda per ogni Array '...
                'presente in sito e le precipitazioni locali rilevate dal pluviometro.']);
            add(Site,sezGrafRLvsPL);
            add(Site,testoRLvsPL);
            testoRLvsPL.HAlign = 'justify';
            figure(22)
            GI_RainLink = bar(GI_Date_RL,GI_Rain_RL,75,'k');
            yyaxis left
            ylabel('Precipitazioni [mm]');
            set(gca,'YColor','k')
            yyaxis right
            ylabel('Variazione di falda [m]');
            set(gca,'YColor','k')
            title('Correlazione piogge - variazioni di falda');
            xlabel('Data [gg/mm/aaaa]');
            strRL(1,1) = cellstr('Precipitazioni');
            legend(strRL,'Location','northwest');
            [~,colPL] = size(GI_Level_PL);
            num = 2;
            index = [];
            hold on
            grid on
            cmap = lines(colPL);
            for p = 1:colPL
                if GI_Date_PL(1,p) ~= 0
                    ind_PL = find(GI_Date_PL(:,p));
                    index = [index; p];
                    GI_RainLink = plot(GI_Date_PL(1:ind_PL(end),p),GI_VarFaldaPL(1:ind_PL(end),p),'-','Color',cmap(p,:));
                    h = gca;
                    h.XAxis.MinorTick = 'on';
                    datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                    xtickangle(20);
                    str(1,num) = cellstr([char(chainID(p,4)) ' -' num2str(GI_Prof_PL(1,p)) 'm']);
                    str(1,1) = cellstr('Precipitazioni');
                    legend(str,'Location','northwest');
                    num = num+1;
                end
            end
            leg = legend(str,'Location','best');
            clear str
            TempName = char(strcat('Report',siteID,'-', char(toolrif),'-RLvsPL.png'));
            saveas(GI_RainLink,TempName);
            ChartRLvsPL = Image(TempName);
            ChartRLvsPL.Style = {ScaleToFit};
            ChartRLvsPL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto tra i dati di precipitazione e variazione '...
                'di falda registrati nel periodo temporale di riferimento']);
            FIG = FIG+1;
            ChartRLvsPL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
            text = (['In questo caso, l''andamento della falda ' char(232) ' riferito alle misure dei sensori riportati di seguito: ']);
            testoRLvsPL2 = Paragraph(text);
            testoRLvsPL2.HAlign = 'justify';
            add(Site,testoRLvsPL2);
            I = size(index);
            for a = 1:I(1)
                text = ['- Array ',char(chainID(index(a),4)),' - Piezometro a ',num2str(GI_Prof_PL(1,index(a))),' m da P.C.'];
                testoRLvsPL2 = Paragraph(text);
                add(Site,testoRLvsPL2);
            end 
            add(Site,ChartRLvsPL);
            add(Site,ChartRLvsPL_cap);
            add(Site,br);
            close(figure(22));
            % -- ENG --
            if activeEN == 1
                sezGrafRLvsPL_ENG = Heading2('Correlation between sensors - Rain Link vs Piezo Link');
                sezGrafRLvsPL_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
                GI_VarFaldaPL = GI_Level_PL-GI_Level_PL(1,:);
                testoRLvsPL = Paragraph(['The following graph aims to highlight '...
                    'the presence of correlations between the piezometer that recorded the '...
                    'the maximum water level variation for each Array present on site, and the  '...
                    'local rainfall data measured by the rain gauge.']);
                add(Site_ENG,sezGrafRLvsPL_ENG);
                add(Site_ENG,testoRLvsPL);
                testoRLvsPL.HAlign = 'justify';
                figure(23)
                GI_RainLink = bar(GI_Date_RL,GI_Rain_RL,75,'k');
                yyaxis left
                ylabel('Rainfall [mm]');
                set(gca,'YColor','k')
                yyaxis right
                ylabel('Water level variation [m]');
                set(gca,'YColor','k')
                title('Correlations between rainfall and water level variation');
                xlabel('Date [dd/mm/yyyy]');
                strRL(1,1) = cellstr('Rainfall');
                legend(strRL,'Location','northwest');
                [~,colPL] = size(GI_Level_PL);
                num = 2;
                index = [];
                hold on
                grid on
                cmap = lines(colPL);
                for p = 1:colPL
                    if GI_Date_PL(1,p) ~= 0
                        ind_PL = find(GI_Date_PL(:,p));
                        index = [index; p];
                        GI_RainLink = plot(GI_Date_PL(1:ind_PL(end),p),GI_VarFaldaPL(1:ind_PL(end),p),'-','Color',cmap(p,:));
                        h = gca;
                        h.XAxis.MinorTick = 'on';
                        datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                        xtickangle(20);
                        str(1,num) = cellstr([char(chainID(p,4)) ' -' num2str(GI_Prof_PL(1,p)) 'm']);
                        str(1,1) = cellstr('Rainfall');
                        legend(str,'Location','northwest');
                        num = num+1;
                    end
                end
                leg = legend(str,'Location','best');
                clear str
                TempName = char(strcat('Report',siteID,'-', char(toolrif),'-RLvsPL_ENG.png'));
                saveas(GI_RainLink,TempName);
                ChartRLvsPL_ENG = Image(TempName);
                ChartRLvsPL_ENG.Style = {ScaleToFit};
                ChartRLvsPL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between '...
                    'rainfall data and water level variation during the reference time period']);
                FIG_ENG = FIG_ENG+1;
                ChartRLvsPL_ENG_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                text = ('In this case, the water level variation data derive from the sensors listed below: ');
                testoRLvsPL2 = Paragraph(text);
                testoRLvsPL2.HAlign = 'justify';
                add(Site_ENG,testoRLvsPL2);
                I = size(index);
                for a = 1:I(1)
                    text = ['- Array ',char(chainID(index(a),4)),' - Piezometer located ',num2str(GI_Prof_PL(1,index(a))),' m b.g.l.'];
                    testoRLvsPL2 = Paragraph(text);
                    add(Site_ENG,testoRLvsPL2);
                end
                add(Site_ENG,ChartRLvsPL_ENG);
                add(Site_ENG,ChartRLvsPL_ENG_cap);
                add(Site_ENG,br);
                close(figure(23));
            end
        end
    end
    
    escludiTL = 0;
    escludiIPL = 0;
    % --- Piogge vs Max Spostamento Tilt Link ---
    if sum(rRL) > 0 && sum(rTL) > 0 && exist('GI_Rain_RL','var') && exist('GI_Disp_TL','var')
        if isempty(GI_Disp_TL) == 0 && isempty(GI_Rain_RL) == 0
           if titleCha == 0
                sezSITE = Heading1('Correlazioni fra i diversi sensori presenti in sito');
                sezSITE.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                Site.Title = sezSITE;
                spazio = Paragraph('');
                add(Site,spazio);
                if activeEN == 1
                    sezSITE_ENG = Heading1('Correlations between different sensors installed on site');
                    sezSITE_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                    Site_ENG.Title = sezSITE_ENG;
                    spazio = Paragraph('');
                    add(Site_ENG,spazio);
                end
                titleCha = 1;
            end
            sezGrafRLvsTL = Heading2('Correlazioni tra sensori - Rain Link vs Tilt Link V');
            sezGrafRLvsTL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            testoRLvsTL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                'evidenziare eventuali correlazioni presenti tra il sensore MEMS 3D '...
                'che ha registrato i maggiori spostamenti per ogni Array '...
                'presente in sito e le precipitazioni locali rilevate dal pluviometro.']);
            add(Site,sezGrafRLvsTL);
            add(Site,testoRLvsTL);
            testoRLvsTL.HAlign = 'justify';
            figure(23)
            GI_RainLink = bar(GI_Date_RL,GI_Rain_RL,75,'k');
            yyaxis left
            ylabel('Precipitazioni [mm]');
            set(gca,'YColor','k')
            yyaxis right
            ylabel('Spostamento [mm]');
            set(gca,'YColor','k')
            title('Correlazione piogge - spostamenti');
            xlabel('Data [gg/mm/aaaa]');
            strRL(1,1) = cellstr('Precipitazioni');
            legend(strRL,'Location','northwest');
            [~,colTL] = size(GI_Disp_TL);
            num = 2;
            hold on
            grid on
            index = [];
            cmap = lines(colTL);
            for t = 1:colTL
                if GI_Date_TL(1,t) ~= 0
                    ind_TL = find(GI_Date_TL(:,t));
                    index = [index; t];
                    GI_RainLink = plot(GI_Date_TL(1:ind_TL(end),t),GI_Disp_TL(1:ind_TL(end),t),'-','Color',cmap(t,:));
                    h = gca;
                    h.XAxis.MinorTick = 'on';
                    datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                    xtickangle(20);
                    str(1,1) = cellstr('Precipitazioni');
                    str(1,num) = cellstr([char(chainID(t,4)) ' ' num2str(GI_Prof_TL(1,t)) 'm']);
                    legend(str,'Location','northwest');
                    num = num+1;
                end
            end
            clear str
            TempName = char(strcat('Report',siteID,'-', char(toolrif),'-RLvsTL.png'));
            saveas(GI_RainLink,TempName);
            ChartRLvsTL = Image(TempName);
            ChartRLvsTL.Style = {ScaleToFit};
            ChartRLvsTL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                'tra i dati di precipitazione e spostamento registrati nel periodo temporale di riferimento']);
            FIG = FIG+1;
            ChartRLvsTL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
            text = 'Gli spostamenti sono riferiti alle misure dei sensori riportati di seguito: ';
            testoRLvsTL2 = Paragraph(text);
            testoRLvsTL2.HAlign = 'justify';
            add(Site,testoRLvsTL2);
            I = size(index);
            for a = 1:I(1)
                text = ['- Array ',char(chainID(index(a),4)),' - MEMS a ',num2str(abs(GI_Prof_TL(1,index(a)))),' m da P.C.'];
                testoRLvsTL2 = Paragraph(text);
                add(Site,testoRLvsTL2);
            end 
            add(Site,ChartRLvsTL);
            add(Site,ChartRLvsTL_cap);
            add(Site,br);
            close(figure(23));
            
            % -- ENG --
            if activeEN == 1
                sezGrafRLvsTL_ENG = Heading2('Correlation between sensors - Rain Link vs Tilt Link V');
                sezGrafRLvsTL_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
                testoRLvsTL = Paragraph(['The following graph aims to highlight the presence '...
                    'of correlations between the maximum displacement measured by the MEMS 3D '...
                    'sensors for each Array installed on site, and the local rainfall data recorded '...
                    'by the rain gauge.']);
                add(Site_ENG,sezGrafRLvsTL_ENG);
                add(Site_ENG,testoRLvsTL);
                testoRLvsTL.HAlign = 'justify';
                figure(24)
                GI_RainLink = bar(GI_Date_RL,GI_Rain_RL,75,'k');
                yyaxis left
                ylabel('Rainfall [mm]');
                set(gca,'YColor','k')
                yyaxis right
                ylabel('Displacement [mm]');
                set(gca,'YColor','k')
                title('Correlation between rainfall and displacements');
                xlabel('Date [dd/mm/yyyy]');
                strRL(1,1) = cellstr('Rainfall');
                legend(strRL,'Location','northwest');
                [~,colTL] = size(GI_Disp_TL);
                num = 2;
                hold on
                grid on
                index = [];
                cmap = lines(colTL);
                for t = 1:colTL
                    if GI_Date_TL(1,t) ~= 0
                        ind_TL = find(GI_Date_TL(:,t));
                        index = [index; t];
                        GI_RainLink = plot(GI_Date_TL(1:ind_TL(end),t),GI_Disp_TL(1:ind_TL(end),t),'-','Color',cmap(t,:));
                        h = gca;
                        h.XAxis.MinorTick = 'on';
                        datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                        xtickangle(20);
                        str(1,1) = cellstr('Rainfall');
                        str(1,num) = cellstr([char(chainID(t,4)) ' ' num2str(GI_Prof_TL(1,t)) 'm']);
                        legend(str,'Location','northwest');
                        num = num+1;
                    end
                end
                clear str
                TempName = char(strcat('Report',siteID,'-', char(toolrif),'-RLvsTL_ENG.png'));
                saveas(GI_RainLink,TempName);
                ChartRLvsTL_ENG = Image(TempName);
                ChartRLvsTL_ENG.Style = {ScaleToFit};
                ChartRLvsTL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between '...
                    'rainfall and displacement data recorded during the reference time period']);
                FIG_ENG = FIG_ENG+1;
                ChartRLvsTL_ENG_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                text = 'The analyzed displacements refer to monitoring data recorded by the following sensors: ';
                testoRLvsTL2 = Paragraph(text);
                testoRLvsTL2.HAlign = 'justify';
                add(Site_ENG,testoRLvsTL2);
                I = size(index);
                for a = 1:I(1)
                    text = ['- Array ',char(chainID(index(a),4)),' - MEMS located ',num2str(abs(GI_Prof_TL(1,index(a)))),' m b.g.l.'];
                    testoRLvsTL2 = Paragraph(text);
                    add(Site_ENG,testoRLvsTL2);
                end
                add(Site_ENG,ChartRLvsTL_ENG);
                add(Site_ENG,ChartRLvsTL_ENG_cap);
                add(Site_ENG,br);
                close(figure(24));
            end
            escludiTL = 1;
        end
    end
    % --- Piogge vs Max Spostamento In Place Link ---
    if sum(rRL) > 0 && sum(rIPL) > 0 && exist('GI_Rain_RL','var') && exist('GI_Disp_IPL','var')
        if isempty(GI_Disp_IPL) == 0 && isempty(GI_Rain_RL) == 0
           if titleCha == 0
                sezSITE = Heading1('Correlazioni fra i diversi sensori presenti in sito');
                sezSITE.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                Site.Title = sezSITE;
                spazio = Paragraph('');
                add(Site,spazio);
                if activeEN == 1
                    sezSITE_ENG = Heading1('Correlations between different sensors installed on site');
                    sezSITE_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                    Site_ENG.Title = sezSITE_ENG;
                    spazio = Paragraph('');
                    add(Site_ENG,spazio);
                end
                titleCha = 1;
            end
            sezGrafRLvsIPL = Heading2('Correlazioni tra sensori - Rain Link vs In Place Link');
            sezGrafRLvsIPL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            testoRLvsIPL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                'evidenziare eventuali correlazioni presenti tra il sensore MEMS 3D '...
                'che ha registrato i maggiori spostamenti per ogni Array '...
                'presente in sito e le precipitazioni locali rilevate dal pluviometro.']);
            add(Site,sezGrafRLvsIPL);
            add(Site,testoRLvsIPL);
            testoRLvsIPL.HAlign = 'justify';
            figure(23)
            GI_RainLink = bar(GI_Date_RL,GI_Rain_RL,75,'k');
            yyaxis left
            ylabel('Precipitazioni [mm]');
            set(gca,'YColor','k')
            yyaxis right
            ylabel('Spostamento [mm]');
            set(gca,'YColor','k')
            title('Correlazione piogge - spostamenti');
            xlabel('Data [gg/mm/aaaa]');
            strRL(1,1) = cellstr('Precipitazioni');
            legend(strRL,'Location','northwest');
            [~,colIPL] = size(GI_Disp_IPL);
            num = 2;
            hold on
            grid on
            index = [];
            cmap = lines(colIPL);
            for t = 1:colIPL
                if GI_Date_IPL(1,t) ~= 0
                    ind_IPL = find(GI_Date_IPL(:,t));
                    index = [index; t];
                    GI_RainLink = plot(GI_Date_IPL(1:ind_IPL(end),t),GI_Disp_IPL(1:ind_IPL(end),t),'-','Color',cmap(t,:));
                    h = gca;
                    h.XAxis.MinorTick = 'on';
                    datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                    xtickangle(20);
                    str(1,num) = cellstr([char(chainID(t,4)) ' ' num2str(GI_Prof_IPL(1,t)) 'm']);
                    num = num+1;
                end
            end
            leg = legend(str,'Location','northwest');
            clear str
            TempName = char(strcat('Report',siteID,'-', char(toolrif),'-RLvsIPL.png'));
            saveas(GI_RainLink,TempName);
            ChartRLvsIPL = Image(TempName);
            ChartRLvsIPL.Style = {ScaleToFit};
            ChartRLvsIPL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                'tra i dati di precipitazione e spostamento registrati nel periodo '...
                'temporale di riferimento']);
            FIG = FIG+1;
            ChartRLvsIPL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
            text = 'Gli spostamenti sono riferiti alle misure dei sensori riportati di seguito: ';
            testoRLvsIPL2 = Paragraph(text);
            testoRLvsIPL2.HAlign = 'justify';
            add(Site,testoRLvsIPL2);
            I = size(index);
            for a = 1:I(1)
                text = ['- Array ',char(chainID(index(a),4)),' - MEMS a ',num2str(abs(GI_Prof_IPL(1,index(a)))),' m da P.C.'];
                testoRLvsIPL2 = Paragraph(text);
                add(Site,testoRLvsIPL2);
            end
            add(Site,ChartRLvsIPL);
            add(Site,ChartRLvsIPL_cap);
            add(Site,br);
            close(figure(23));
            
            % -- ENG --
            if activeEN == 1
                sezGrafRLvsIPL_ENG = Heading2('Correlation between sensors - Rain Link vs In Place Link');
                sezGrafRLvsIPL_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
                testoRLvsIPL = Paragraph(['The following graph aims to highlight the presence '...
                    'of correlations between the maximum displacement measured by the MEMS 3D '...
                    'sensors for each Array installed on site, and the local rainfall data recorded '...
                    'by the rain gauge.']);
                add(Site_ENG,sezGrafRLvsIPL_ENG);
                add(Site_ENG,testoRLvsIPL);
                testoRLvsIPL.HAlign = 'justify';
                figure(23)
                GI_RainLink = bar(GI_Date_RL,GI_Rain_RL,75,'k');
                yyaxis left
                ylabel('Rainfall [mm]');
                set(gca,'YColor','k')
                yyaxis right
                ylabel('Displacement [mm]');
                set(gca,'YColor','k')
                title('Correlation between rainfall and displacements');
                xlabel('Date [dd/mm/yyyy]');
                strRL(1,1) = cellstr('Rainfall');
                legend(strRL,'Location','northwest');
                [~,colIPL] = size(GI_Disp_IPL);
                num = 2;
                hold on
                grid on
                index = [];
                cmap = lines(colIPL);
                for t = 1:colIPL
                    if GI_Date_IPL(1,t) ~= 0
                        ind_IPL = find(GI_Date_IPL(:,t));
                        index = [index; t];
                        GI_RainLink = plot(GI_Date_IPL(1:ind_IPL(end),t),GI_Disp_IPL(1:ind_IPL(end),t),'-','Color',cmap(t,:));
                        h = gca;
                        h.XAxis.MinorTick = 'on';
                        datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                        xtickangle(20);
                        str(1,num) = cellstr([char(chainID(t,4)) ' ' num2str(GI_Prof_IPL(1,t)) 'm']);
                        num = num+1;
                    end
                end
                leg = legend(str,'Location','northwest');
                clear str
                TempName = char(strcat('Report',siteID,'-', char(toolrif),'-RLvsIPL_ENG.png'));
                saveas(GI_RainLink,TempName);
                ChartRLvsIPL_ENG = Image(TempName);
                ChartRLvsIPL_ENG.Style = {ScaleToFit};
                ChartRLvsIPL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between '...
                    'rainfall and displacement data recorded during the reference time period']);
                FIG_ENG = FIG_ENG+1;
                ChartRLvsIPL_ENG_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                text = 'The analyzed displacements refer to monitoring data recorded by the following sensors: ';
                testoRLvsIPL2 = Paragraph(text);
                testoRLvsIPL2.HAlign = 'justify';
                add(Site_ENG,testoRLvsIPL2);
                I = size(index);
                for a = 1:I(1)
                    text = ['- Array ',char(chainID(index(a),4)),' - MEMS located ',num2str(abs(GI_Prof_IPL(1,index(a)))),' m b.g.l.'];
                    testoRLvsIPL2 = Paragraph(text);
                    add(Site_ENG,testoRLvsIPL2);
                end
                add(Site_ENG,ChartRLvsIPL_ENG);
                add(Site_ENG,ChartRLvsIPL_ENG_cap);
                add(Site_ENG,br);
                close(figure(23));
            end
            escludiIPL = 1;
        end
    end
    % --- Spostamenti Tilt Link o In Place Link - clinometri - fessurimetri ---
    if sum(rTL) > 0 && exist('GI_Disp_TL','var') && sum(rKL) > 0 && exist('GI_Angolo_KL','var') || ...
            sum(rIPL) > 0 && exist('GI_Disp_IPL','var') && sum(rKL) > 0 && exist('GI_Angolo_KL','var') || ...
            sum(rTL) > 0 && exist('GI_Disp_TL','var') && sum(rCrL) > 0 && exist('GI_Disp_CrL','var') || ...
            sum(rIPL) > 0 && exist('GI_Disp_IPL','var') && sum(rCrL) > 0 && exist('GI_Disp_CrL','var') || ...
            sum(rCrL) > 0 && exist('GI_Disp_CrL','var') && sum(rKL) > 0 && exist('GI_Angolo_KL','var')
        if isempty(GI_Disp_TL) == 0 && isempty(GI_Angolo_KL) == 0 || ...
                isempty(GI_Disp_IPL) == 0 && isempty(GI_Angolo_KL) == 0 || ...
                isempty(GI_Disp_TL) == 0 && isempty(GI_Disp_CrL) == 0 || ...
                isempty(GI_Disp_IPL) == 0 && isempty(GI_Disp_CrL) == 0 || ...
                isempty(GI_Disp_CrL) == 0 && isempty(GI_Angolo_KL) == 0
            figure(25)
            hold on
            grid on
            if sum(rTL) > 0 && sum(rKL) > 0 && sum(rCrL) > 0 % Ci sono Tilt + Klino + Crack
               sezGrafTLvsKL = Heading2('Correlazioni tra sensori Tilt Link V, Klino Link e Crack Link');
               testoTLvsKL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                    'evidenziare eventuali correlazioni presenti tra '...
                    'i maggiori spostamenti differenziali registrati per ogni Array dai sensori MEMS 3D, '...
                    'la massima inclinazione differenziale lungo gli assi strumentali registrata '...
                    'dai clinometri e la maggior apertura o chiusura rilevata dai fessurimetri presenti in sito.']);
                title('Valori massimi dei sensori Tilt, Klino e Crack Link');
                ChartTLvsKL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                'tra i dati differenziali massimi di spostamento, inclinazione ed apertura '...
                'o chiusura di fessure registrati rispettivamente dai sensori inclinometrici, '...
                'clinometrici e fessurimetri di ogni singolo Array, nel periodo temporale di riferimento']);
            elseif sum(rIPL) > 0 && sum(rKL) > 0 && sum(rCrL) > 0 % Ci sono In Place + Klino + Crack
               sezGrafTLvsKL = Heading2('Correlazioni tra sensori In Place Link, Klino Link e Crack Link');
               testoTLvsKL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                    'evidenziare eventuali correlazioni presenti tra '...
                    'i maggiori spostamenti differenziali registrati per ogni Array dai sensori MEMS 3D, '...
                    'la massima inclinazione differenziale lungo gli assi strumentali registrata '...
                    'dai clinometri e la maggior apertura o chiusura rilevata dai fessurimetri presenti in sito.']);
                title('Valori massimi dei sensori In Place, Klino e Crack Link');
                ChartTLvsKL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                'tra i dati differenziali massimi di spostamento, inclinazione ed apertura '...
                'o chiusura di fessure registrati rispettivamente dai sensori inclinometrici, '...
                'clinometrici e fessurimetri di ogni singolo Array, nel periodo temporale di riferimento']);
            elseif sum(rTL) > 0 && sum(rKL) > 0 % Tilt + Klino
                sezGrafTLvsKL = Heading2('Correlazioni tra sensori Tilt Link V e Klino Link');
                testoTLvsKL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                    'evidenziare eventuali correlazioni presenti tra '...
                    'i maggiori spostamenti differenziali registrati per ogni Array dai sensori MEMS 3D '...
                    'e la massima inclinazione differenziale lungo gli assi strumentali registrata '...
                    'dai clinometri presenti in sito.']);
                title('Valori massimi dei sensori Tilt e Klino Link');
                ChartTLvsKL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                    'tra i dati differenziali massimi di spostamento e di inclinazione '...
                    'registrati rispettivamente dai sensori inclinometrici e '...
                    'clinometrici di ogni singolo Array, nel periodo temporale di riferimento']);
            elseif sum(rIPL) > 0 && sum(rKL) > 0 % In Place + Klino
                sezGrafTLvsKL = Heading2('Correlazioni tra sensori In Place Link e Klino Link');
                testoTLvsKL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                    'evidenziare eventuali correlazioni presenti tra '...
                    'i maggiori spostamenti differenziali registrati per ogni Array dai sensori MEMS 3D '...
                    'e la massima inclinazione differenziale lungo gli assi strumentali registrata '...
                    'dai clinometri presenti in sito.']);
                title('Valori massimi dei sensori In Place e Klino Link');
                ChartTLvsKL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                    'tra i dati differenziali massimi di spostamento e di inclinazione '...
                    'registrati rispettivamente dai sensori inclinometrici e '...
                    'clinometrici di ogni singolo Array, nel periodo temporale di riferimento']);
            elseif sum(rTL) > 0 && sum(rCrL) > 0 % Tilt e Crack
                sezGrafTLvsKL = Heading2('Correlazioni tra sensori Tilt Link V e Crack Link');
                testoTLvsKL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                    'evidenziare eventuali correlazioni presenti tra '...
                    'i maggiori spostamenti differenziali registrati per ogni Array dai sensori MEMS 3D '...
                    'e la maggior apertura o chiusura rilevata dai fessurimetri presenti in sito.']);
                title('Valori massimi dei sensori Tilt e Crack Link');
                ChartTLvsKL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                    'tra i dati differenziali massimi di spostamento ed apertura '...
                    'o chiusura di fessure registrati rispettivamente dai sensori inclinometrici '...
                    'e fessurimetri di ogni singolo Array, nel periodo temporale di riferimento']);
            elseif sum(rIPL) > 0 && sum(rCrL) > 0 % In Place e Crack
                sezGrafTLvsKL = Heading2('Correlazioni tra sensori In Place Link e Crack Link');
                testoTLvsKL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                    'evidenziare eventuali correlazioni presenti tra '...
                    'i maggiori spostamenti differenziali registrati per ogni Array dai sensori MEMS 3D '...
                    'e la maggior apertura o chiusura rilevata dai fessurimetri presenti in sito.']);
                title('Valori massimi dei sensori Tilt e Crack Link');
                ChartTLvsKL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                    'tra i dati differenziali massimi di spostamento ed apertura '...
                    'o chiusura di fessure registrati rispettivamente dai sensori inclinometrici '...
                    'e fessurimetri di ogni singolo Array, nel periodo temporale di riferimento']);
            elseif sum(rKL) > 0 && sum(rCrL) > 0
                sezGrafTLvsKL = Heading2('Correlazioni tra sensori Klino Link e Crack Link');
                testoTLvsKL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                    'evidenziare eventuali correlazioni presenti tra '...
                    'la massima inclinazione differenziale rilevata lungo gli assi strumentali '...
                    'dei clinometri e la maggior apertura o chiusura rilevata dai fessurimetri presenti in sito.']);
                title('Valori massimi dei sensori Klino e Crack Link');
                ChartTLvsKL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                    'tra i dati differenziali massimi di inclinazione ed apertura '...
                    'o chiusura di fessure registrati rispettivamente dai sensori '...
                    'clinometrici e fessurimetri di ogni singolo Array, nel periodo temporale di riferimento']);
            end
            sezGrafTLvsKL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            testoTLvsKL.HAlign = 'justify';
            
            yyaxis left
            ylabel('Spostamento [mm]');
            set(gca,'YColor','k')
            yyaxis right
            ylabel(['Inclinazione [' char(176) ']']);
            set(gca,'YColor','k')
            xlabel('Data [gg/mm/aaaa]');
            [~,colTL] = size(GI_Disp_TL);
            [~,colIPL] = size(GI_Disp_IPL);
            [~,colKL] = size(GI_Date_KL);
            [~,colCrL] = size(GI_Date_CrL);
            num = 1;
            cmap = lines(2*colKL+colTL+colIPL+colCrL);
            cont = 1;
            % Tilt Link V
            indexTL = [];
            if sum(rTL) > 0
                yyaxis left
                for t = 1:colTL
                    if GI_Date_TL(1,t) ~= 0
                        ind_TL = find(GI_Date_TL(:,t));
                        indexTL = [indexTL; t];
                        plot(GI_Date_TL(1:ind_TL(end),t),GI_Disp_TL(1:ind_TL(end),t),'-','Color',cmap(cont,:));
                        cont = cont+1;
                        h = gca;
                        h.XAxis.MinorTick = 'on';
                        datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                        xtickangle(20);
                        str(1,num) = cellstr([char(chainID(t,4)) ' ' num2str(GI_Prof_TL(1,t)) ' m']);
                        num = num+1;
                    end
                end
                MIN(1) = min(min(GI_Disp_TL));
                MAX(1) = max(max(GI_Disp_TL));
            end
            % In Place Link
            indexIPL = [];
            if sum(rIPL) > 0
                yyaxis left
                for t = 1:colIPL
                    if GI_Date_IPL(1,t) ~= 0
                        ind_IPL = find(GI_Date_IPL(:,t));
                        indexIPL = [indexIPL; t];
                        plot(GI_Date_IPL(1:ind_IPL(end),t),GI_Disp_IPL(1:ind_IPL(end),t),'-','Color',cmap(cont,:));
                        cont = cont+1;
                        h = gca;
                        h.XAxis.MinorTick = 'on';
                        datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                        xtickangle(20);
                        str(1,num) = cellstr([char(chainID(t,4)) ' ' num2str(GI_Prof_IPL(1,t)) ' m']);
                        num = num+1;
                    end
                end
                MIN(2) = min(min(GI_Disp_IPL));
                MAX(2) = max(max(GI_Disp_IPL));
            end
            % Crack Link
            indexCrL = [];
            if sum(rCrL) > 0
                yyaxis left
                for c = 1:colCrL
                    if GI_Date_CrL(1,c) ~= 0
                        var = GI_Disp_CrL-GI_Disp_CrL(1,:);
                        ind_CrL = find(GI_Date_CrL(:,c));
                        indexCrL = [indexCrL; c];
                        if sum(rKL) > 0
                            plot(GI_Date_CrL(1:ind_CrL(end),c),var(1:ind_CrL(end),c),'-','Color',cmap(cont,:));
                        else
                            GI_KlinoLink = plot(GI_Date_CrL(1:ind_CrL(end),c),var(1:ind_CrL(end),c),'-','Color',cmap(cont,:));
                        end
                        cont = cont+1;
                        h = gca;
                        h.XAxis.MinorTick = 'on';
                        datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                        xtickangle(20);
                        str(1,num) = cellstr([char(chainID(c,4)) ' nodo ' num2str(GI_Num_CrL(1,c))]);
                        num = num+1;
                    end
                end
                MIN(3) = min(min(var));
                MAX(3) = max(max(var));
                ylim([floor(min(min(MIN))) ceil(max(max(MAX)))]);
            end
            
            % Klino Link
            indexKL = [];
            if sum(rKL) > 0
                yyaxis right
                kk = 1;
                for k = 1:colKL
                    if GI_Date_KL(1,k) ~= 0
                        ind_KL = find(GI_Date_KL(:,k));
                        indexKL = [indexKL; k];
                        plot(GI_Date_KL(1:ind_KL(end),k),GI_Angolo_KL(1:ind_KL(end),kk)...
                            -GI_Angolo_KL(1,kk),'-','Color',cmap(cont,:));
                        GI_KlinoLink = plot(GI_Date_KL(1:ind_KL(end),k),GI_Angolo_KL(1:ind_KL(end)...
                                ,kk+1)-GI_Angolo_KL(1,kk+1),'-','Color',cmap(cont+1,:));
                        cont = cont+2;
                        kk = kk+2;
                        h = gca;
                        h.XAxis.MinorTick = 'on';
                        datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                        xtickangle(20);
                        str(1,num) = cellstr([char(chainID(k,4)) ' nodo ' num2str(GI_Num_KL(1,k)) ' asse X']);
                        str(1,num+1) = cellstr([char(chainID(k,4)) ' nodo ' num2str(GI_Num_KL(1,k)) ' asse Y']);
                        num = num+2;
                    end
                end
                yyaxis right
                ylim([floor(min(min(GI_Angolo_KL))) ceil(max(max(GI_Angolo_KL)))]);
            end
            
            numcolumns = 1;
            [legend_h,object_h,plot_h,text_strings] = columnlegend(numcolumns,str,'Location','NorthWest');
            TempName = char(strcat('Report',siteID,'-', char(toolrif),'-TLvsKL.png'));
           if titleCha == 0
                sezSITE = Heading1('Correlazioni fra i diversi sensori presenti in sito');
                sezSITE.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                Site.Title = sezSITE;
                spazio = Paragraph('');
                add(Site,spazio);
                if activeEN == 1
                    sezSITE_ENG = Heading1('Correlations between different sensors installed on site');
                    sezSITE_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                    Site_ENG.Title = sezSITE_ENG;
                    spazio = Paragraph('');
                    add(Site_ENG,spazio);
                end
                titleCha = 1;
            end
            add(Site,sezGrafTLvsKL);
            add(Site,testoTLvsKL);
            saveas(GI_KlinoLink,TempName);
            ChartTLvsKL = Image(TempName);
            ChartTLvsKL.Style = {ScaleToFit};
            
            FIG = FIG+1;
            ChartTLvsKL_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
            text = 'I dati sono riferiti alle misure dei sensori riportati di seguito: ';
            testoTL2 = Paragraph(text);
            testoTL2.HAlign = 'justify';
            add(Site,testoTL2);
            % Tilt Link
            I = size(indexTL);
            for a = 1:I(1)
                text = ['- Array ',char(chainID(indexTL(a),4)),' - MEMS a ',num2str(abs(GI_Prof_TL(1,indexTL(a)))),' m da P.C.'];
                testoTL2 = Paragraph(text);
                add(Site,testoTL2);
            end
            % In Place Link
            I = size(indexIPL);
            for a = 1:I(1)
                text = ['- Array ',char(chainID(indexIPL(a),4)),' - MEMS a ',num2str(abs(GI_Prof_IPL(1,indexIPL(a)))),' m da P.C.'];
                testoTL2 = Paragraph(text);
                add(Site,testoTL2);
            end
            % Klino Link
            I = size(indexKL);
            for a = 1:I(1)
                text = ['- Array ',char(chainID(indexKL(a),4)),' - Clinometro numero ',num2str(GI_Num_KL(1,indexKL(a)))];
                testoTL2 = Paragraph(text);
                add(Site,testoTL2);
            end
            % Crack Link
            I = size(indexCrL);
            for a = 1:I(1)
                text = ['- Array ',char(chainID(indexCrL(a),4)),' - Fessurimetro numero ',num2str(GI_Num_CrL(1,indexCrL(a)))];
                testoTL2 = Paragraph(text);
                add(Site,testoTL2);
            end
            add(Site,ChartTLvsKL);
            add(Site,ChartTLvsKL_cap);
            add(Site,br);
            close(figure(25));
            
            % --- ENG ---
            if activeEN == 1
                figure(35)
                hold on
                grid on
                if sum(rTL) > 0 && sum(rKL) > 0 && sum(rCrL) > 0 % Ci sono Tilt + Klino + Crack
                    sezGrafTLvsKL_ENG = Heading2('Correlation between sensors: Tilt Link V, Klino Link, and Crack Link');
                    testoTLvsKL = Paragraph(['The following graph has the objective to '...
                        'highlight the presence of correlations between '...
                        'the maximum differential displacements recorded for each Array by 3D MEMS sensors, '...
                        'the maximum differential tilt recorded by tilt meters along the instrumental axes, '...
                        'and the maximum crack opening variation measured by crack meters installed on site.']);
                    title('Maximum values recorded by Tilt, Klino, and Crack Links');
                    ChartTLvsKL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between '...
                        'maximum differential displacements, tilt, and crack opening data'...
                        'recorded during the reference time period respectively by '...
                        'Tilt Link, Klino Link, and Crack Link sensors integrated in each single Array']);
                elseif sum(rIPL) > 0 && sum(rKL) > 0 && sum(rCrL) > 0 % Ci sono In Place + Klino + Crack
                    sezGrafTLvsKL_ENG = Heading2('Correlation between sensors: In Place Link, Klino Link, and Crack Link');
                    testoTLvsKL = Paragraph(['The following graph has the objective to '...
                        'highlight the presence of correlations between '...
                        'the maximum differential displacements recorded for each Array by 3D MEMS sensors, '...
                        'the maximum differential tilt recorded by tilt meters along the instrumental axes, '...
                        'and the maximum crack opening variation measured by crack meters installed on site.']);
                    title('Maximum values recorded by In Place, Klino, and Crack Links');
                    ChartTLvsKL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between '...
                        'maximum differential displacements, tilt, and crack opening data'...
                        'recorded during the reference time period respectively by '...
                        'In Place Link, Klino Link, and Crack Link sensors integrated in each single Array']);
                elseif sum(rTL) > 0 && sum(rKL) > 0 % Tilt + Klino
                    sezGrafTLvsKL_ENG = Heading2('Correlation between sensors: Tilt Link V and Klino Link');
                    testoTLvsKL = Paragraph(['The following graph has the objective to '...
                        'highlight the presence of correlations between '...
                        'the maximum differential displacements recorded for each Array by 3D MEMS sensors, and '...
                        'the maximum differential tilt recorded along the instrumental axes by the tilt meters '...
                        'installed on site.']);
                    title('Maximum values recorded by Tilt Link and Klino Link');
                    ChartTLvsKL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between '...
                        'maximum differential displacements and tilt data'...
                        'recorded during the reference time period respectively by '...
                        'Tilt Link and Klino Link sensors integrated in each single Array']);
                elseif sum(rIPL) > 0 && sum(rKL) > 0 % In Place + Klino
                    sezGrafTLvsKL_ENG = Heading2('Correlation between sensors: In Place Link and Klino Link');
                    testoTLvsKL = Paragraph(['The following graph has the objective to '...
                        'highlight the presence of correlations between '...
                        'the maximum differential displacements recorded for each Array by 3D MEMS sensors, and '...
                        'the maximum differential tilt recorded along the instrumental axes by the tilt meters '...
                        'installed on site.']);
                    title('Maximum values recorded by In Place Link and Klino Link');
                    ChartTLvsKL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between '...
                        'maximum differential displacements and tilt data'...
                        'recorded during the reference time period respectively by '...
                        'In Place Link and Klino Link sensors integrated in each single Array']);
                elseif sum(rTL) > 0 && sum(rCrL) > 0 % Tilt e Crack
                   sezGrafTLvsKL_ENG = Heading2('Correlation between sensors: Tilt Link V and Crack Link');
                    testoTLvsKL = Paragraph(['The following graph has the objective to '...
                        'highlight the presence of correlations between '...
                        'the maximum differential displacements recorded for each Array by 3D MEMS sensors, '...
                        'and the maximum crack opening variation measured by crack meters installed on site.']);
                    title('Maximum values recorded by Tilt and Crack Links');
                    ChartTLvsKL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between '...
                        'maximum differential displacements and crack opening data'...
                        'recorded during the reference time period respectively by '...
                        'Tilt Link and Crack Link sensors integrated in each single Array']);
                elseif sum(rIPL) > 0 && sum(rCrL) > 0 % In Place e Crack
                   sezGrafTLvsKL_ENG = Heading2('Correlation between sensors: In Place and Crack Link');
                    testoTLvsKL = Paragraph(['The following graph has the objective to '...
                        'highlight the presence of correlations between '...
                        'the maximum differential displacements recorded for each Array by 3D MEMS sensors, '...
                        'and the maximum crack opening variation measured by crack meters installed on site.']);
                    title('Maximum values recorded by In Place and Crack Links');
                    ChartTLvsKL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between '...
                        'maximum differential displacements and crack opening data'...
                        'recorded during the reference time period respectively by '...
                        'In Place Link and Crack Link sensors integrated in each single Array']);
                elseif sum(rKL) > 0 && sum(rCrL) > 0
                    sezGrafTLvsKL_ENG = Heading2('Correlation between sensors: Klino Link and Crack Link');
                    testoTLvsKL = Paragraph(['The following graph has the objective to '...
                        'highlight the presence of correlations between '...
                        'the maximum differential tilt recorded by tilt meters along the instrumental axes '...
                        'and the maximum crack opening variation measured by crack meters installed on site.']);
                    title('Maximum values recorded by Klino and Crack Links');
                    ChartTLvsKL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between '...
                        'tilt and crack opening data'...
                        'recorded during the reference time period respectively by '...
                        'Klino Link and Crack Link sensors integrated in each single Array']);
                end
                sezGrafTLvsKL_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
                testoTLvsKL.HAlign = 'justify';
                
                yyaxis left
                ylabel('Displacement [mm]');
                set(gca,'YColor','k')
                yyaxis right
                ylabel(['Tilt [' char(176) ']']);
                set(gca,'YColor','k')
                xlabel('Date [dd/mm/yyyy]');
                [~,colTL] = size(GI_Disp_TL);
                [~,colIPL] = size(GI_Disp_IPL);
                [~,colKL] = size(GI_Date_KL);
                [~,colCrL] = size(GI_Date_CrL);
                num = 1;
                cmap = lines(2*colKL+colTL+colIPL+colCrL);
                cont = 1;
                % Tilt Link V
                indexTL = [];
                if sum(rTL) > 0
                    yyaxis left
                    for t = 1:colTL
                        if GI_Date_TL(1,t) ~= 0
                            ind_TL = find(GI_Date_TL(:,t));
                            indexTL = [indexTL; t];
                            plot(GI_Date_TL(1:ind_TL(end),t),GI_Disp_TL(1:ind_TL(end),t),'-','Color',cmap(cont,:));
                            cont = cont+1;
                            h = gca;
                            h.XAxis.MinorTick = 'on';
                            datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                            xtickangle(20);
                            str(1,num) = cellstr([char(chainID(t,4)) ' ' num2str(GI_Prof_TL(1,t)) ' m']);
                            num = num+1;
                        end
                    end
                    MIN(1) = min(min(GI_Disp_TL));
                    MAX(1) = max(max(GI_Disp_TL));
                end
                % In Place Link
                indexIPL = [];
                if sum(rIPL) > 0
                    yyaxis left
                    for t = 1:colIPL
                        if GI_Date_IPL(1,t) ~= 0
                            ind_IPL = find(GI_Date_IPL(:,t));
                            indexIPL = [indexIPL; t];
                            plot(GI_Date_IPL(1:ind_IPL(end),t),GI_Disp_IPL(1:ind_IPL(end),t),'-','Color',cmap(cont,:));
                            cont = cont+1;
                            h = gca;
                            h.XAxis.MinorTick = 'on';
                            datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                            xtickangle(20);
                            str(1,num) = cellstr([char(chainID(t,4)) ' ' num2str(GI_Prof_IPL(1,t)) ' m']);
                            num = num+1;
                        end
                    end
                    MIN(2) = min(min(GI_Disp_IPL));
                    MAX(2) = max(max(GI_Disp_IPL));
                end
                % Crack Link
                indexCrL = [];
                if sum(rCrL) > 0
                    yyaxis left
                    for c = 1:colCrL
                        if GI_Date_CrL(1,c) ~= 0
                            var = GI_Disp_CrL-GI_Disp_CrL(1,:);
                            ind_CrL = find(GI_Date_CrL(:,c));
                            indexCrL = [indexCrL; c];
                            if sum(rKL) > 0
                                plot(GI_Date_CrL(1:ind_CrL(end),c),var(1:ind_CrL(end),c),'-','Color',cmap(cont,:));
                            else
                                GI_KlinoLink = plot(GI_Date_CrL(1:ind_CrL(end),c),var(1:ind_CrL(end),c),'-','Color',cmap(cont,:));
                            end
                            cont = cont+1;
                            h = gca;
                            h.XAxis.MinorTick = 'on';
                            datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                            xtickangle(20);
                            str(1,num) = cellstr([char(chainID(c,4)) ' node ' num2str(GI_Num_CrL(1,c))]);
                            num = num+1;
                        end
                    end
                    MIN(3) = min(min(var));
                    MAX(3) = max(max(var));
                    ylim([floor(min(min(MIN))) ceil(max(max(MAX)))]);
                end
                
                % Klino Link
                indexKL = [];
                if sum(rKL) > 0
                    yyaxis right
                    kk = 1;
                    for k = 1:colKL
                        if GI_Date_KL(1,k) ~= 0
                            ind_KL = find(GI_Date_KL(:,k));
                            indexKL = [indexKL; k];
                            plot(GI_Date_KL(1:ind_KL(end),k),GI_Angolo_KL(1:ind_KL(end),kk)...
                                -GI_Angolo_KL(1,kk),'-','Color',cmap(cont,:));
                            GI_KlinoLink = plot(GI_Date_KL(1:ind_KL(end),k),GI_Angolo_KL(1:ind_KL(end)...
                                ,kk+1)-GI_Angolo_KL(1,kk+1),'-','Color',cmap(cont+1,:));
                            cont = cont+2;
                            kk = kk+2;
                            h = gca;
                            h.XAxis.MinorTick = 'on';
                            datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                            xtickangle(20);
                            str(1,num) = cellstr([char(chainID(k,4)) ' node ' num2str(GI_Num_KL(1,k)) ' - X axis']);
                            str(1,num+1) = cellstr([char(chainID(k,4)) ' node ' num2str(GI_Num_KL(1,k)) ' - Y axis']);
                            num = num+2;
                        end
                    end
                    yyaxis right
                    ylim([floor(min(min(GI_Angolo_KL))) ceil(max(max(GI_Angolo_KL)))]);
                end
                
                numcolumns = 1;
                [legend_h,object_h,plot_h,text_strings] = columnlegend(numcolumns,str,'Location','NorthWest');
                TempName = char(strcat('Report',siteID,'-', char(toolrif),'-TLvsKL_ENG.png'));

                add(Site_ENG,sezGrafTLvsKL_ENG);
                add(Site_ENG,testoTLvsKL);
                saveas(GI_KlinoLink,TempName);
                ChartTLvsKL_ENG = Image(TempName);
                ChartTLvsKL_ENG.Style = {ScaleToFit};
                
                FIG_ENG = FIG_ENG+1;
                ChartTLvsKL_ENG_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                text = 'Monitoring data refer to the sensors listed below: ';
                testoTL2 = Paragraph(text);
                testoTL2.HAlign = 'justify';
                add(Site_ENG,testoTL2);
                % Tilt Link
                I = size(indexTL);
                for a = 1:I(1)
                    text = ['- Array ',char(chainID(indexTL(a),4)),' - MEMS located ',num2str(abs(GI_Prof_TL(1,indexTL(a)))),' m b.g.l.'];
                    testoTL2 = Paragraph(text);
                    add(Site_ENG,testoTL2);
                end
                % In Place Link
                I = size(indexIPL);
                for a = 1:I(1)
                    text = ['- Array ',char(chainID(indexIPL(a),4)),' - MEMS located ',num2str(abs(GI_Prof_IPL(1,indexIPL(a)))),' m b.g.l.'];
                    testoTL2 = Paragraph(text);
                    add(Site_ENG,testoTL2);
                end
                % Klino Link
                I = size(indexKL);
                for a = 1:I(1)
                    text = ['- Array ',char(chainID(indexKL(a),4)),' - Tilt meter ',num2str(GI_Num_KL(1,indexKL(a)))];
                    testoTL2 = Paragraph(text);
                    add(Site_ENG,testoTL2);
                end
                % Crack Link
                I = size(indexCrL);
                for a = 1:I(1)
                    text = ['- Array ',char(chainID(indexCrL(a),4)),' - Crack meter ',num2str(GI_Num_CrL(1,indexCrL(a)))];
                    testoTL2 = Paragraph(text);
                    add(Site_ENG,testoTL2);
                end
                add(Site_ENG,ChartTLvsKL_ENG);
                add(Site_ENG,ChartTLvsKL_ENG_cap);
                add(Site_ENG,br);
                close(figure(35));
            end            
        end
        escludiTL = 1;
    end

    % --- Spostamenti a confronto ---
    % ---> Tilt Link
    if sum(rTL) > 0 && exist('GI_Disp_TL','var')
        if isempty(GI_Disp_TL) == 0
            if escludiTL == 0
                sezGrafTL = Heading2('Correlazioni tra sensori Tilt Link V');
                sezGrafTL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
                testoTL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                    'evidenziare eventuali correlazioni presenti tra '...
                    'i maggiori spostamenti registrati per ogni Array dai sensori MEMS 3D '...
                    'presenti in sito.']);
                testoTL.HAlign = 'justify';
                figure(24)
                ylabel('Spostamento [mm]');
                set(gca,'YColor','k')
                title('Correlazione fra gli spostamenti massimi di ogni Array');
                xlabel('Data [gg/mm/aaaa]');
                [~,colTL] = size(GI_Disp_TL);
                num = 1;
                index = [];
                for t = 1:colTL
                    if GI_Date_TL(1,t) ~= 0
                        ind_TL = find(GI_Date_TL(:,t));
                        index = [index; t];
                        hold on
                        grid on
                        GI_TiltLink = plot(GI_Date_TL(1:ind_TL(end),t),GI_Disp_TL(1:ind_TL(end),t));
                        h = gca;
                        h.XAxis.MinorTick = 'on';
                        str(1,num) = cellstr([char(chainID(t,4)) ' ' num2str(GI_Prof_TL(1,t)) ' m']);
                        num = num+1;
                    end
                end
                Max = max(GI_Disp_TL(1:ind_TL(end),:));
                MAX = max(Max);
                if MAX < 10 % mm
                    ylim([0 10]);
                end
                datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                xtickangle(20);
                legend(str,'Location','northwest');
                TempName = char(strcat('Report',siteID,'-', char(toolrif),'-TL.png'));
                if num >= 3
                    if titleCha == 0
                        sezSITE = Heading1('Correlazioni fra i diversi sensori presenti in sito');
                        sezSITE.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                        Site.Title = sezSITE;
                        spazio = Paragraph('');
                        add(Site,spazio);
                        if activeEN == 1
                            sezSITE_ENG = Heading1('Correlations between different sensors installed on site');
                            sezSITE_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                            Site_ENG.Title = sezSITE_ENG;
                            spazio = Paragraph('');
                            add(Site_ENG,spazio);
                        end
                        titleCha = 1;
                    end
                    add(Site,sezGrafTL);
                    add(Site,testoTL);
                    saveas(GI_TiltLink,TempName);
                    ChartTL = Image(TempName);
                    ChartTL.Style = {ScaleToFit};
                    ChartTL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                        'tra i dati massimi di spostamento registrati da ogni singolo Array nel periodo temporale di riferimento']);
                    FIG = FIG+1;
                    ChartTL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                    text = 'Gli spostamenti sono riferiti alle misure dei sensori riportati di seguito: ';
                    testoTL2 = Paragraph(text);
                    testoTL2.HAlign = 'justify';
                    add(Site,testoTL2);
                    I = size(index);
                    for a = 1:I(1)
                        text = ['- Array ',char(chainID(index(a),4)),' - MEMS a ',num2str(abs(GI_Prof_TL(1,index(a)))),' m da P.C.'];
                        testoTL2 = Paragraph(text);
                        add(Site,testoTL2);
                    end
                    add(Site,ChartTL);
                    add(Site,ChartTL_cap);
                    add(Site,br);
                end
                close(figure(24));
                
                % -- ENG --
                if activeEN == 1
                    sezGrafTL_ENG = Heading2('Correlation between Tilt Link V sensors');
                    sezGrafTL_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
                    testoTL = Paragraph(['The following graph aims to highlight the presence '...
                        'of correlations between the most relevant displacements recorded by '...
                        '3D MEMS sensors for each single Array installed on site.']);
                    testoTL.HAlign = 'justify';
                    figure(34)
                    ylabel('Displacement [mm]');
                    set(gca,'YColor','k')
                    title('Correlation between maximum displacements recorded by each Array');
                    xlabel('Date [dd/mm/yyyy]');
                    [~,colTL] = size(GI_Disp_TL);
                    num = 1;
                    index = [];
                    for t = 1:colTL
                        if GI_Date_TL(1,t) ~= 0
                            ind_TL = find(GI_Date_TL(:,t));
                            index = [index; t];
                            hold on
                            grid on
                            GI_TiltLink = plot(GI_Date_TL(1:ind_TL(end),t),GI_Disp_TL(1:ind_TL(end),t));
                            h = gca;
                            h.XAxis.MinorTick = 'on';
                            str(1,num) = cellstr([char(chainID(t,4)) ' ' num2str(GI_Prof_TL(1,t)) ' m']);
                            num = num+1;
                        end
                    end
                    Max = max(GI_Disp_TL(1:ind_TL(end),:));
                    MAX = max(Max);
                    if MAX < 10 % mm
                        ylim([0 10]);
                    end
                    datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                    xtickangle(20);
                    legend(str,'Location','northwest');
                    TempName = char(strcat('Report',siteID,'-', char(toolrif),'-TL_ENG.png'));
                    if num >= 3
                        add(Site_ENG,sezGrafTL_ENG);
                        add(Site_ENG,testoTL);
                        saveas(GI_TiltLink,TempName);
                        ChartTL_ENG = Image(TempName);
                        ChartTL_ENG.Style = {ScaleToFit};
                        ChartTL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between maximum '...
                            'displacement data recorded by each Array during the reference time period']);
                        FIG_ENG = FIG_ENG+1;
                        ChartTL_ENG_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                        text = 'Displacement data refers to the 3D MEMS sensors listed below: ';
                        testoTL2 = Paragraph(text);
                        testoTL2.HAlign = 'justify';
                        add(Site_ENG,testoTL2);
                        I = size(index);
                        for a = 1:I(1)
                            text = ['- Array ',char(chainID(index(a),4)),' - MEMS located ',num2str(abs(GI_Prof_TL(1,index(a)))),' m b.g.l.'];
                            testoTL2 = Paragraph(text);
                            add(Site_ENG,testoTL2);
                        end
                        add(Site_ENG,ChartTL_ENG);
                        add(Site_ENG,ChartTL_ENG_cap);
                        add(Site_ENG,br);
                    end
                    close(figure(34));
                end
            end
        end
    end
    % ---> In Place Link
    if sum(rIPL) > 0 && exist('GI_Disp_IPL','var')
        if isempty(GI_Disp_IPL) == 0
            if escludiIPL == 0
                sezGrafIPL = Heading2('Correlazioni tra sensori In Place Link');
                sezGrafIPL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
                testoIPL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                    'evidenziare eventuali correlazioni presenti tra '...
                    'i maggiori spostamenti registrati per ogni Array dai sensori MEMS 3D '...
                    'presenti in sito.']);
                testoIPL.HAlign = 'justify';
                figure(24)
                ylabel('Spostamento [mm]');
                set(gca,'YColor','k')
                title('Correlazione fra gli spostamenti massimi di ogni Array');
                xlabel('Data [gg/mm/aaaa]');
                [~,colIPL] = size(GI_Disp_IPL);
                num = 1;
                index = [];
                for t = 1:colIPL
                    if GI_Date_IPL(1,t) ~= 0
                        ind_IPL = find(GI_Date_IPL(:,t));
                        index = [index; t];
                        hold on
                        grid on
                        GI_InPlaceLink = plot(GI_Date_IPL(1:ind_IPL(end),t),GI_Disp_IPL(1:ind_IPL(end),t));
                        h = gca;
                        h.XAxis.MinorTick = 'on';
                        str(1,num) = cellstr([char(chainID(t,4)) ' ' num2str(GI_Prof_IPL(1,t)) ' m']);
                        num = num+1;
                    end
                end
                Max = max(GI_Disp_IPL(1:ind_IPL(end),:));
                MAX = max(Max);
                if MAX < 10 % mm
                    ylim([0 10]);
                end
                datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                xtickangle(20);
                legend(str,'Location','northwest');
                TempName = char(strcat('Report',siteID,'-', char(toolrif),'-IPL.png'));
                if num >= 3
                    if titleCha == 0
                        sezSITE = Heading1('Correlazioni fra i diversi sensori presenti in sito');
                        sezSITE.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                        Site.Title = sezSITE;
                        spazio = Paragraph('');
                        add(Site,spazio);
                        if activeEN == 1
                            sezSITE_ENG = Heading1('Correlations between different sensors installed on site');
                            sezSITE_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                            Site_ENG.Title = sezSITE_ENG;
                            spazio = Paragraph('');
                            add(Site_ENG,spazio);
                        end
                        titleCha = 1;
                    end
                    add(Site,sezGrafIPL);
                    add(Site,testoIPL);
                    saveas(GI_InPlaceLink,TempName);
                    ChartIPL = Image(TempName);
                    ChartIPL.Style = {ScaleToFit};
                    ChartIPL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                        'tra i dati massimi di spostamento registrati da ogni '...
                        'singolo Array nel periodo temporale di riferimento']);
                    FIG = FIG+1;
                    ChartIPL_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                    text = 'Gli spostamenti sono riferiti alle misure dei sensori riportati di seguito: ';
                    testoIPL2 = Paragraph(text);
                    testoIPL2.HAlign = 'justify';
                    add(Site,testoIPL2);
                    I = size(index);
                    for a = 1:I(1)
                        text = ['- Array ',char(chainID(index(a),4)),' - MEMS a ',num2str(abs(GI_Prof_IPL(1,index(a)))),' m da P.C.'];
                        testoIPL2 = Paragraph(text);
                        add(Site,testoIPL2);
                    end
                    add(Site,ChartIPL);
                    add(Site,ChartIPL_cap);
                    add(Site,br);
                end
                close(figure(24));
                
                % --- ENG ---
                if activeEN == 1
                    sezGrafIPL_ENG = Heading2('Correlation between Tilt Link V sensors');
                    sezGrafIPL_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
                    testoIPL = Paragraph(['The following graph aims to highlight the presence '...
                        'of correlations between the most relevant displacements recorded by '...
                        '3D MEMS sensors for each single Array installed on site.']);
                    testoIPL.HAlign = 'justify';
                    figure(34)
                    ylabel('Displacement [mm]');
                    set(gca,'YColor','k')
                    title('Correlation between maximum displacements recorded by each Array');
                    xlabel('Date [dd/mm/yyyy]');
                    [~,colIPL] = size(GI_Disp_IPL);
                    num = 1;
                    index = [];
                    for t = 1:colIPL
                        if GI_Date_IPL(1,t) ~= 0
                            ind_IPL = find(GI_Date_IPL(:,t));
                            index = [index; t];
                            hold on
                            grid on
                            GI_InPlaceLink = plot(GI_Date_IPL(1:ind_IPL(end),t),GI_Disp_IPL(1:ind_IPL(end),t));
                            h = gca;
                            h.XAxis.MinorTick = 'on';
                            str(1,num) = cellstr([char(chainID(t,4)) ' ' num2str(GI_Prof_IPL(1,t)) ' m']);
                            num = num+1;
                        end
                    end
                    Max = max(GI_Disp_IPL(1:ind_IPL(end),:));
                    MAX = max(Max);
                    if MAX < 10 % mm
                        ylim([0 10]);
                    end
                    datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                    xtickangle(20);
                    legend(str,'Location','northwest');
                    TempName = char(strcat('Report',siteID,'-', char(toolrif),'-IPL_ENG.png'));
                    if num >= 3
                        add(Site_ENG,sezGrafIPL_ENG);
                        add(Site_ENG,testoIPL);
                        saveas(GI_InPlaceLink,TempName);
                        ChartIPL_ENG = Image(TempName);
                        ChartIPL_ENG.Style = {ScaleToFit};
                        ChartIPL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between maximum '...
                            'displacement data recorded by each Array during the reference time period']);
                        FIG_ENG = FIG_ENG+1;
                        ChartIPL_ENG_cap.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                        text = 'Displacement data refers to the 3D MEMS sensors listed below: ';
                        testoIPL2 = Paragraph(text);
                        testoIPL2.HAlign = 'justify';
                        add(Site_ENG,testoIPL2);
                        I = size(index);
                        for a = 1:I(1)
                            text = ['- Array ',char(chainID(index(a),4)),' - MEMS located ',num2str(abs(GI_Prof_IPL(1,index(a)))),' m b.g.l.'];
                            testoIPL2 = Paragraph(text);
                            add(Site_ENG,testoIPL2);
                        end
                        add(Site_ENG,ChartIPL_ENG);
                        add(Site_ENG,ChartIPL_ENG_cap);
                        add(Site_ENG,br);
                    end
                    close(figure(34));
                end
            end
        end
    end
    %--->  Quadranti Tunnel Link
    if sum(rTuL) > 0 && exist('GI_Q1_TuL','var')
        if isempty(GI_Q1_TuL) == 0 && isempty(GI_Q2_TuL) == 0 && isempty(GI_Q3_TuL) == 0 ...
                && isempty(GI_Q4_TuL) == 0
            if titleCha == 0
                sezSITE = Heading1('Correlazioni fra i diversi sensori presenti in sito');
                sezSITE.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                Site.Title = sezSITE;
                spazio = Paragraph('');
                add(Site,spazio);
                if activeEN == 1
                    sezSITE_ENG = Heading1('Correlations between different sensors installed on site');
                    sezSITE_ENG.Style = {OuterMargin('0in','0in','0in','0in'),FontSize(Font_Chapter),HAlign('justify')};
                    Site_ENG.Title = sezSITE_ENG;
                    spazio = Paragraph('');
                    add(Site_ENG,spazio);
                end
                titleCha = 1;
            end
            sezGrafTuL = Heading2('Correlazioni tra sensori Tunnel Link');
            sezGrafTuL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            testoTuL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                'evidenziare eventuali correlazioni presenti tra '...
                'i maggiori spostamenti 2D registrati nel piano della sezione '...
                'dai sensori MEMS 3D installati in sito, per ogni quadrante '...
                'delle sezioni monitorate. Si ricorda che '...
                'i quadranti sono definiti suddividendo la sezione in quattro '...
                'zone, considerando le linee di mezzeria e mezza altezza. '...
                'L''ordine dei quadranti segue il principio della circonferenza '...
                'goniometrica, per cui il primo quadrante ' char(232) ' quello presente in alto '...
                'a destra e gli altri sono numerati in senso antiorario. '...
                'A titolo di esempio, la figura successiva identifica i 4 quadranti '...
                'per una sezione tipo.']);
            testoTuL.HAlign = 'justify';
            img = Image(('Quadranti.png'));
            img.Style = {Height('6cm'),HAlign('center')};
            imgcaption = Paragraph(['Fig. ' num2str(FIG) ' - Esempio di sezione tipo con relativi quadranti']);
            FIG = FIG+1;
            imgcaption.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
            % Quadrante 1
            figure(25)
            set(gca,'YColor','k')
            [~,colTuL] = size(GI_Q1_TuL);
            num = 1;
            for t = 1:colTuL
                if GI_Date_TuL(1,t) ~= 0
                    y1(num) = GI_Q1_TuL(1,t);
                    y2(num) = GI_Q2_TuL(1,t);
                    y3(num) = GI_Q3_TuL(1,t);
                    y4(num) = GI_Q4_TuL(1,t);
                    y5(num) = 0;
                    str(1,num) = chainID(t,4);
                    num = num+1;
                end
            end
            y = [y1;y2;y3;y4;y5];
            x = [1;2;3;4;5];
            Quadranti = barh(x,y);
            grid on

            title('Correlazione fra gli spostamenti dei singoli quadranti');
            xlabel('Spostamento [mm]');
            ylabel('Quadrante [-]');
            ylim([0 5]); % Con 5, metto la legenda in alto a sx (il valore 5 è pieno di 0)
            % Stimo limiti asse X
            ini1 = min(GI_Q1_TuL);
            ini2 = min(GI_Q2_TuL);
            ini3 = min(GI_Q3_TuL);
            ini4 = min(GI_Q4_TuL);
            Min = [ini1; ini2; ini3; ini4];
            C = min(Min);
            end1 = max(GI_Q1_TuL);
            end2 = max(GI_Q2_TuL);
            end3 = max(GI_Q3_TuL);
            end4 = max(GI_Q4_TuL);
            Max = [end1; end2; end3; end4];
            B = max(Max);
            A = [abs(C),abs(B)];
            LIM = max(A);
            POS = find(A == LIM);
            if -LIM > -2.5 % mm
                ini = -2.5;
            else
                ini = -LIM;
            end
            if LIM < 2.5
                End = 2.5;
            else
                End = LIM;
            end
            xlim([ini End]);
            if num-1 == 1 % 1 solo array
                ylim([0 5]);
            else
                ylim([0 6]);
            end
            yticks(1:4);
            if POS == 1 % Legenda a DX
               legend(str,'Location','northeast');
            else % SX
                legend(str,'Location','northwest');
            end
                
            add(Site,sezGrafTuL);
            add(Site,testoTuL);
            add(Site,img);
            add(Site,imgcaption);
            
            TempName1 = char(strcat('Report',siteID,'-', char(toolrif),'-Quadranti.png'));
            saveas(Quadranti(1),TempName1);
            ChartTuL = Image(TempName1);
            ChartTuL.Style = {ScaleToFit};
            close(figure(25))        
            Quadranti_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                'tra i dati massimi di spostamento 2D, registrati per ogni singolo '...
                'quadrante della sezione nel periodo temporale di riferimento, '...
                'dai sensori dei Cir Array presenti in sito']);
            FIG = FIG+1;
            Quadranti_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};

            text = 'Gli spostamenti sono riferiti alle misure dei sensori riportati di seguito: ';
            testoTuL2 = Paragraph(text);
            testoTuL2.HAlign = 'justify';
            add(Site,testoTuL2);
            text = 'Quadrante 1';
            testoTuL1 = Paragraph(text);
            testoTuL1.Style = {HAlign('justify'),FontSize(Font_caption),Bold(1),Color('midnightblue')};
            add(Site,testoTuL1);
            for a = 1:colTuL
                if GI_Date_TuL(1,a) ~= 0
                    text1 = ['- Array ',char(chainID(a,4)),' - nodo numero ',num2str(abs(GI_Q1_Num_TuL(1,a))),''];
                    testoTuL2 = Paragraph(text1);
                    add(Site,testoTuL2);
                end
            end
            text = 'Quadrante 2';
            testoTuL3 = Paragraph(text);
            testoTuL3.Style = {HAlign('justify'),FontSize(Font_caption),Bold(1),Color('midnightblue')};
            add(Site,testoTuL3);
            for a = 1:colTuL
                if GI_Date_TuL(1,a) ~= 0
                    text2 = ['- Array ',char(chainID(a,4)),' - nodo numero ',num2str(abs(GI_Q2_Num_TuL(1,a))),''];
                    testoTuL4 = Paragraph(text2);
                    add(Site,testoTuL4);
                end
            end
            text = 'Quadrante 3';
            testoTuL5 = Paragraph(text);
            testoTuL5.Style = {HAlign('justify'),FontSize(Font_caption),Bold(1),Color('midnightblue')};
            add(Site,testoTuL5);
            for a = 1:colTuL
                if GI_Date_TuL(1,a) ~= 0
                    text3 = ['- Array ',char(chainID(a,4)),' - nodo numero ',num2str(abs(GI_Q3_Num_TuL(1,a))),''];
                    testoTuL6 = Paragraph(text3);
                    add(Site,testoTuL6);
                end
            end
            text = 'Quadrante 4';
            testoTuL7 = Paragraph(text);
            testoTuL7.Style = {HAlign('justify'),FontSize(Font_caption),Bold(1),Color('midnightblue')};
            add(Site,testoTuL7);
            for a = 1:colTuL
                if GI_Date_TuL(1,a) ~= 0
                    text4 = ['- Array ',char(chainID(a,4)),' - nodo numero ',num2str(abs(GI_Q4_Num_TuL(1,a))),''];
                    testoTuL8 = Paragraph(text4);
                    add(Site,testoTuL8);
                end
            end
            add(Site,ChartTuL);
            add(Site,Quadranti_cap);
            
            % --- ENG ---
            if activeEN == 1
                sezGrafTuL_ENG = Heading2('Correlation between Tunnel Link sensors');
                sezGrafTuL_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
                testoTuL = Paragraph(['The following graph aims to highlight any correlation between '...
                'highest 2D displacement values recorded by 3D MEMS for each single Cir Array installed on-site. '...
                'Displacements are compared according to the corresponding sector, defined by dividing the monitored '...
                'section in four separated areas that are numbered as explained in the following figure. ']);
                testoTuL.HAlign = 'justify';
                img = Image(('Quadranti.png'));
                img.Style = {Height('6cm'),HAlign('center')};
                imgcaption = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Sectors numbering in a tunnel section']);
                FIG_ENG = FIG_ENG+1;
                imgcaption.Style = {HAlign('center'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                % Quadrante 1
                figure(35)
                set(gca,'YColor','k')
                [~,colTuL] = size(GI_Q1_TuL);
                num = 1;
                for t = 1:colTuL
                    if GI_Date_TuL(1,t) ~= 0
                        y1(num) = GI_Q1_TuL(1,t);
                        y2(num) = GI_Q2_TuL(1,t);
                        y3(num) = GI_Q3_TuL(1,t);
                        y4(num) = GI_Q4_TuL(1,t);
                        y5(num) = 0;
                        str(1,num) = chainID(t,4);
                        num = num+1;
                    end
                end
                y = [y1;y2;y3;y4;y5];
                x = [1;2;3;4;5];
                Quadranti = barh(x,y);
                grid on
                
                title('Correlation between displacements recorded in different sectors');
                xlabel('Displacement [mm]');
                ylabel('Sector [-]');
                ylim([0 5]); % Con 5, metto la legenda in alto a sx (il valore 5 è pieno di 0)
                % Stimo limiti asse X
                ini1 = min(GI_Q1_TuL);
                ini2 = min(GI_Q2_TuL);
                ini3 = min(GI_Q3_TuL);
                ini4 = min(GI_Q4_TuL);
                Min = [ini1; ini2; ini3; ini4];
                C = min(Min);
                end1 = max(GI_Q1_TuL);
                end2 = max(GI_Q2_TuL);
                end3 = max(GI_Q3_TuL);
                end4 = max(GI_Q4_TuL);
                Max = [end1; end2; end3; end4];
                B = max(Max);
                A = [abs(C),abs(B)];
                LIM = max(A);
                POS = find(A == LIM);
                if -LIM > -2.5 % mm
                    ini = -2.5;
                else
                    ini = -LIM;
                end
                if LIM < 2.5
                    End = 2.5;
                else
                    End = LIM;
                end
                xlim([ini End]);
                if num-1 == 1 % 1 solo array
                    ylim([0 5]);
                else
                    ylim([0 6]);
                end
                yticks(1:4);
                if POS == 1 % Legenda a DX
                    legend(str,'Location','northeast');
                else % SX
                    legend(str,'Location','northwest');
                end
                
                add(Site_ENG,sezGrafTuL_ENG);
                add(Site_ENG,testoTuL);
                add(Site_ENG,img);
                add(Site_ENG,imgcaption);
                
                TempName1 = char(strcat('Report',siteID,'-', char(toolrif),'-Quadranti_ENG.png'));
                saveas(Quadranti(1),TempName1);
                ChartTuL_ENG = Image(TempName1);
                ChartTuL_ENG.Style = {ScaleToFit};
                close(figure(35))
                Quadranti_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison '...
                    'between highest 2D displacement values '...
                    'recorded by each single Array in the corresponding '...
                    'sector of the monitored tunnel section '...
                    'during the reference time period']);
                FIG_ENG = FIG_ENG+1;
                Quadranti_ENG_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                
                text = 'Displacement data refer to the sensors listed below: ';
                testoTuL2 = Paragraph(text);
                testoTuL2.HAlign = 'justify';
                add(Site_ENG,testoTuL2);
                text = 'Sector 1';
                testoTuL1 = Paragraph(text);
                testoTuL1.Style = {HAlign('justify'),FontSize(Font_caption),Bold(1),Color('midnightblue')};
                add(Site_ENG,testoTuL1);
                for a = 1:colTuL
                    if GI_Date_TuL(1,a) ~= 0
                        text1 = ['- Array ',char(chainID(a,4)),' - node ',num2str(abs(GI_Q1_Num_TuL(1,a))),''];
                        testoTuL2 = Paragraph(text1);
                        add(Site_ENG,testoTuL2);
                    end
                end
                text = 'Sector 2';
                testoTuL3 = Paragraph(text);
                testoTuL3.Style = {HAlign('justify'),FontSize(Font_caption),Bold(1),Color('midnightblue')};
                add(Site_ENG,testoTuL3);
                for a = 1:colTuL
                    if GI_Date_TuL(1,a) ~= 0
                        text2 = ['- Array ',char(chainID(a,4)),' - node ',num2str(abs(GI_Q2_Num_TuL(1,a))),''];
                        testoTuL4 = Paragraph(text2);
                        add(Site_ENG,testoTuL4);
                    end
                end
                text = 'Sector 3';
                testoTuL5 = Paragraph(text);
                testoTuL5.Style = {HAlign('justify'),FontSize(Font_caption),Bold(1),Color('midnightblue')};
                add(Site_ENG,testoTuL5);
                for a = 1:colTuL
                    if GI_Date_TuL(1,a) ~= 0
                        text3 = ['- Array ',char(chainID(a,4)),' - node ',num2str(abs(GI_Q3_Num_TuL(1,a))),''];
                        testoTuL6 = Paragraph(text3);
                        add(Site_ENG,testoTuL6);
                    end
                end
                text = 'Sector 4';
                testoTuL7 = Paragraph(text);
                testoTuL7.Style = {HAlign('justify'),FontSize(Font_caption),Bold(1),Color('midnightblue')};
                add(Site_ENG,testoTuL7);
                for a = 1:colTuL
                    if GI_Date_TuL(1,a) ~= 0
                        text4 = ['- Array ',char(chainID(a,4)),' - node ',num2str(abs(GI_Q4_Num_TuL(1,a))),''];
                        testoTuL8 = Paragraph(text4);
                        add(Site_ENG,testoTuL8);
                    end
                end
                add(Site_ENG,ChartTuL_ENG);
                add(Site_ENG,Quadranti_ENG_cap);
            end
        end
    end
    % ---> Confronti variazioni segmenti Stella
    if sum(rTuL) > 0 && exist('GI_Seg_TuL','var')
        if isempty(GI_Seg_TuL) == 0
            testoStar = Paragraph(['Il grafico seguente confronta nella medesima '...
                'rappresentazione le variazioni di lunghezza dei segmenti di convergenza '...
                'delle sezioni monitorate da ciascun Cir Array. Nel rispettivo capitolo '...
                'di ogni catena ' char(232) ' riportata la stella di convergenza per ogni '...
                'sezione.']);
            testoStar.HAlign = 'justify';
            figure(26)
            set(gca,'YColor','k')
            s = 1;
            num = 1;
            [~,colTuL] = size(GI_Date_TuL);
            for t = 1:colTuL
                if GI_Date_TuL(1,t) ~= 0 % Esistono dati per quell'array
                    % Segmento 1
                    s1(num) = GI_Seg_TuL(1,s);
                    s = s+1;
                    % Segmento 2
                    if GI_NumSeg_TuL(t,1) > 1
                        s2(num) = GI_Seg_TuL(1,s);
                        s = s+1;
                    else
                        s2(num) = 0;
                    end
                    % Segmento 3
                    if GI_NumSeg_TuL(t,1) > 2
                        s3(num) = GI_Seg_TuL(1,s);
                        s = s+1;
                    else
                        s3(num) = 0;
                    end
                    % Segmento 4
                    if GI_NumSeg_TuL(t,1) > 3
                        s4(num) = GI_Seg_TuL(1,s);
                        s = s+1;
                    else
                        s4(num) = 0;
                    end
                    % Segmento 5
                    if GI_NumSeg_TuL(t,1) > 4
                        s5(num) = GI_Seg_TuL(1,s);
                        s = s+1;
                    else
                        s5(num) = 0;
                    end
                    % Segmento 6
                    if GI_NumSeg_TuL(t,1) > 5
                        s6(num) = GI_Seg_TuL(1,s);
                        s = s+1;
                    else
                        s6(num) = 0;
                    end
                    % Segmento 7
                    if GI_NumSeg_TuL(t,1) > 6
                        s7(num) = GI_Seg_TuL(1,s);
                        s = s+1;
                    else
                        s7(num) = 0;
                    end
                    str(1,num) = chainID(t,4);
                    num = num+1;
                end
            end
            y = [s1;s2;s3;s4;s5;s6;s7];
            x = [1;2;3;4;5;6;7];
            yticklabels({'S1','S2','S3','S4','S5','S6','S7'})
            Stella = barh(x,y);
            grid on
            
            title('Correlazione fra le variazioni di lunghezza dei segmenti di convergenza');
            xlabel('Spostamento [mm]');
            ylabel('Segmento [-]');
            % Stimo limiti asse X
            ini = min(y);
            ini = min(ini);
            End = max(y);
            End = max(End);
            A = [abs(ini),End];
            RIF = max(A);
            ind = find(A == RIF);
            if ind == 1
                legend(str,'Location','northeast');
            else
                legend(str,'Location','northwest');
            end
            if -RIF > -2.5 % mm
                ini = -2.5;
            else
                ini = -RIF;
            end
            if RIF < 2.5
                End = 2.5;
            else
                End = RIF;
            end
            xlim([ini End]);
            yticks(1:7);
            if num-1 == 1 % Numero Array
                ylim([0 7]);
            else
                ylim([0 8]);
            end
            add(Site,testoStar);
            
            TempName1 = char(strcat('Report',siteID,'-', char(toolrif),'-Stella.png'));
            saveas(Stella(1),TempName1);
            ChartStella = Image(TempName1);
            ChartStella.Style = {ScaleToFit};
            add(Site,ChartStella);
            close(figure(26))
            Quadranti_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                'tra le variazioni di lunghezza dei segmenti di convergenza, registrati '...
                'per le sezioni monitorate nel periodo temporale di riferimento, '...
                'dai sensori degli Array presenti in sito']);
            FIG = FIG+1;
            Quadranti_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
            add(Site,Quadranti_cap);
            add(Site,br);
            
            % --- ENG ---
            if activeEN == 1
                testoStar = Paragraph(['The following graph aims to compare the length variation of '...
                    'each convergence segment referred to tunnel sections monitored with a Cir Array. '...
                    'Please refer to the corresponding Array section of this Report for additional'...
                    'information regarding each specific convergence star.']);
                testoStar.HAlign = 'justify';
                figure(36)
                set(gca,'YColor','k')
                s = 1;
                num = 1;
                [~,colTuL] = size(GI_Date_TuL);
                for t = 1:colTuL
                    if GI_Date_TuL(1,t) ~= 0 % Esistono dati per quell'array
                        % Segmento 1
                        s1(num) = GI_Seg_TuL(1,s);
                        s = s+1;
                        % Segmento 2
                        if GI_NumSeg_TuL(t,1) > 1
                            s2(num) = GI_Seg_TuL(1,s);
                            s = s+1;
                        else
                            s2(num) = 0;
                        end
                        % Segmento 3
                        if GI_NumSeg_TuL(t,1) > 2
                            s3(num) = GI_Seg_TuL(1,s);
                            s = s+1;
                        else
                            s3(num) = 0;
                        end
                        % Segmento 4
                        if GI_NumSeg_TuL(t,1) > 3
                            s4(num) = GI_Seg_TuL(1,s);
                            s = s+1;
                        else
                            s4(num) = 0;
                        end
                        % Segmento 5
                        if GI_NumSeg_TuL(t,1) > 4
                            s5(num) = GI_Seg_TuL(1,s);
                            s = s+1;
                        else
                            s5(num) = 0;
                        end
                        % Segmento 6
                        if GI_NumSeg_TuL(t,1) > 5
                            s6(num) = GI_Seg_TuL(1,s);
                            s = s+1;
                        else
                            s6(num) = 0;
                        end
                        % Segmento 7
                        if GI_NumSeg_TuL(t,1) > 6
                            s7(num) = GI_Seg_TuL(1,s);
                            s = s+1;
                        else
                            s7(num) = 0;
                        end
                        str(1,num) = chainID(t,4);
                        num = num+1;
                    end
                end
                y = [s1;s2;s3;s4;s5;s6;s7];
                x = [1;2;3;4;5;6;7];
                yticklabels({'S1','S2','S3','S4','S5','S6','S7'})
                Stella = barh(x,y);
                grid on
                
                title('Correlation between convergence segments length variation');
                xlabel('Displacement [mm]');
                ylabel('Segment number [-]');
                % Stimo limiti asse X
                ini = min(y);
                ini = min(ini);
                End = max(y);
                End = max(End);
                A = [abs(ini),End];
                RIF = max(A);
                ind = find(A == RIF);
                if ind == 1
                    legend(str,'Location','northeast');
                else
                    legend(str,'Location','northwest');
                end
                if -RIF > -2.5 % mm
                    ini = -2.5;
                else
                    ini = -RIF;
                end
                if RIF < 2.5
                    End = 2.5;
                else
                    End = RIF;
                end
                xlim([ini End]);
                yticks(1:7);
                if num-1 == 1 % Numero Array
                    ylim([0 7]);
                else
                    ylim([0 8]);
                end
                add(Site_ENG,testoStar);
                
                TempName1 = char(strcat('Report',siteID,'-', char(toolrif),'-Stella_ENG.png'));
                saveas(Stella(1),TempName1);
                ChartStella_ENG = Image(TempName1);
                ChartStella_ENG.Style = {ScaleToFit};
                add(Site_ENG,ChartStella_ENG);
                close(figure(36))
                Quadranti_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison '...
                'between length variations of each convergence segment, '...
                'recorded in the corresponding tunnel section by each single Array '...
                'during the reference time period']);
                FIG_ENG = FIG_ENG+1;
                Quadranti_ENG_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                add(Site_ENG,Quadranti_ENG_cap);
                add(Site_ENG,br);
            end
        end
    end
    % ---> Grafici spostamento in calotta PreConv vs Cir
    if sum(rTuL) > 0 && exist('GI_Z_TuL','var') && sum(rPCL) > 0 && exist('GI_Z_PCL','var')
        if isempty(GI_Z_TuL) == 0 && isempty(GI_Z_PCL) == 0
            sezGrafTuLvsPCL = Heading2('Correlazioni tra PreConv Array e Cir Array');
            sezGrafTuLvsPCL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            testoTuLvsPCL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                'evidenziare eventuali correlazioni presenti tra gli spostamenti '...
                'locali registrati in calotta dal PreConv Array e dai corrispondenti '...
                'Cir Array, con riferimento ai sensori installati nei medesimi punti '...
                '(o in quelli pi' char(249) ' prossimi tra di loro).']);
            testoTuLvsPCL.HAlign = 'justify';
            
            % Cerco eventuali correlazioni con Cir Array
            NomeFile = strcat('Report',siteID,'-PCLvsTuL.txt');
            Filetesto = importdata(NomeFile);
            [rF,~] = size(Filetesto);
            AAA = 1;
            num = 1;
            sen = 1;
            SensoriTuL = zeros(1,1);
            SensoriPCL = zeros(1,1);
            CatenaTuL = cell(1,1);
            CatenaPCL = cell(1,1);
            colCIR = 0;
            while AAA < rF % A un PreConv possono competere più Cir
                PCL = 0;
                Cir = 0;
                check1 = Filetesto(AAA,1);
                if check1 == 99999 % Non ci sono PreConv Array o non ci sono Cir
                    break
                else
                    check2 = Filetesto(AAA+1,1);
                    for nn = 1:rAR
                        chain = char(chainID(nn,4));
                        if check1 == str2num(chain(end-2:end))
                            PCL = nn;
                            NodoPCL = Filetesto(AAA+2,1);
                            SensoriPCL(sen,1) = NodoPCL;
                            CatenaPCL(sen,1) = chainID(nn,4);
                        end
                        if check2 == str2num(chain(end-2:end))
                            Cir = nn;
                            NodoTuL = Filetesto(AAA+3,1);
                            SensoriTuL(sen,1) = NodoTuL;
                            CatenaTuL(sen,1) = chainID(nn,4);
                            colCIR = colCIR+1;
                        end
                        if PCL > 0 && Cir > 0
                            figure(27)
                            ylabel('Spostamento [mm]');
                            xlabel('Data [gg/mm/aaaa]');
                            set(gca,'YColor','k')
                            title('Correlazione fra gli spostamenti corrispondenti');
                            grid on
                            hold on
                            dim1 = find(GI_Z_PCL(:,PCL));
                            dim2 = find(GI_Z_TuL(:,colCIR));
                            if isempty(dim1) == 0 && isempty(dim2) == 0
                               plot(GI_Date_PCL(1:dim1(end),PCL),GI_Z_PCL(1:dim1(end),PCL));
                               GI_TuLvsPCL = plot(GI_Date_TuL(1:dim2(end),Cir),GI_Z_TuL(1:dim2(end),colCIR));
                               MIN1 = min(GI_Z_PCL(:,PCL));
                               MIN2 = min(GI_Z_TuL(:,colCIR));
                               MIN = min(MIN1,MIN2);
                               MAX1 = max(GI_Z_PCL(:,PCL));
                               MAX2 = max(GI_Z_TuL(:,colCIR));
                               MAX = max(MAX1,MAX2);
                               if MAX < 5 && MIN > -5 % mm
                                   ylim([-5 5]);
                               elseif MAX < 5
                                   ylim([MIN-1 5]);
                               elseif MIN > -5
                                   ylim([-5 MAX+1]);
                               end
                               datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                               h = gca;
                               h.XAxis.MinorTick = 'on';
                               xtickangle(20);
                               str(1,1) = cellstr([char(CatenaPCL(sen,1)) ' Nodo ' num2str(NodoPCL) '']);
                               str(1,2) = cellstr([char(CatenaTuL(sen,1)) ' Nodo ' num2str(NodoTuL) '']);
                               legend(str,'Location','northwest');
                               TempName = char(strcat('Report',siteID,'-PCLvsTuL',num2str(num),'.png'));
                               saveas(GI_TuLvsPCL,TempName);
                               num = num+1;
                            end
                            close(figure(27));
                            sen = sen+1;
                            AAA = AAA+4;
                            break
                        end
                    end
                end
            end
            num = num-1;
            if num ~= 0 % Non ci sono legami
                add(Site,sezGrafTuLvsPCL);
                add(Site,testoTuLvsPCL);
                if num == 1 
                    TempName = char(strcat('Report',siteID,'-PCLvsTuL',num2str(num),'.png'));
                    Chart1 = Image(TempName);
                    Chart1.Style = {ScaleToFit};
                    add(Site,Chart1);
                else
                    n = 1;
                    while n <= num
                        TempName = char(strcat('Report',siteID,'-PCLvsTuL',num2str(n),'.png'));
                        Chart1 = Image(TempName);
                        Chart1.Style = {Height('7cm')};
                        if n+1 <= num
                            TempName = char(strcat('Report',siteID,'-PCLvsTuL',num2str(n+1),'.png'));
                            Chart2 = Image(TempName);
                            Chart2.Style = {Height('7cm')};
                            lot = Table({Chart1, Chart2});
                            lot.Style = {ResizeToFitContents(false), Width('100%')};
                            n = n+2;
                            add(Site,lot);
                        else
                            n = n+1;
                            add(Site,Chart1);
                        end
                    end
                end 
                ChartPCLvsTuL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                    'tra i dati di spostamento locale registrati dal nodo '...
                    'del Cir Array installato in calotta ed il corrispondente '...
                    'sensore PreConv Link pi' char(249) ' in prossimit' char(224) ', nel '...
                    'periodo temporale di riferimento']);
                FIG = FIG+1;
                ChartPCLvsTuL_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                add(Site,ChartPCLvsTuL_cap);
                
                text = 'Gli spostamenti sono riferiti alle misure dei sensori riportati di seguito: ';
                testoPCLvsTuL2 = Paragraph(text);
                testoPCLvsTuL2.HAlign = 'justify';
                add(Site,testoPCLvsTuL2);
                I = size(SensoriPCL);
                for a = 1:I(1)
                    textPC = ['- PreConv Array ' char(CatenaPCL(a,1)) ' - Nodo numero ' num2str(SensoriPCL(a,1)) ';'];
                    textCA = ['- Cir Array ' char(CatenaTuL(a,1)),' - Nodo numero ' num2str(SensoriTuL(a,1)) '.'];
                    spazio = Paragraph('');
                    testoPCLvsTuL2 = Paragraph(textPC);
                    testoPCLvsTuL3 = Paragraph(textCA);
                    add(Site,testoPCLvsTuL2);
                    add(Site,testoPCLvsTuL3);
                    add(Site,spazio);
                end
                add(Site,br);
            end
            
            % --- ENG ---
            if activeEN == 1
                sezGrafTuLvsPCL_ENG = Heading2('Correlation between PreConv Array and Cir Array');
                sezGrafTuLvsPCL_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
                testoTuLvsPCL = Paragraph(['The following graph aims to highlight any correlation '...
                'between local displacements recorded by PreConv Array and Cir Array sensors. The comparison '...
                'takes into account two nodes, one for each Array, installed approximately '...
                'in the same place of the upper part of the monitored section.']);
                testoTuLvsPCL.HAlign = 'justify';
                
                % Cerco eventuali correlazioni con Cir Array
                NomeFile = strcat('Report',siteID,'-PCLvsTuL.txt');
                Filetesto = importdata(NomeFile);
                [rF,~] = size(Filetesto);
                AAA = 1;
                num = 1;
                sen = 1;
                SensoriTuL = zeros(1,1);
                SensoriPCL = zeros(1,1);
                CatenaTuL = cell(1,1);
                CatenaPCL = cell(1,1);
                colCIR = 0;
                while AAA < rF % A un PreConv possono competere più Cir
                    PCL = 0;
                    Cir = 0;
                    check1 = Filetesto(AAA,1);
                    if check1 == 99999 % Non ci sono PreConv Array o non ci sono Cir
                        break
                    else
                        check2 = Filetesto(AAA+1,1);
                        for nn = 1:rAR
                            chain = char(chainID(nn,4));
                            if check1 == str2num(chain(end-2:end))
                                PCL = nn;
                                NodoPCL = Filetesto(AAA+2,1);
                                SensoriPCL(sen,1) = NodoPCL;
                                CatenaPCL(sen,1) = chainID(nn,4);
                            end
                            if check2 == str2num(chain(end-2:end))
                                Cir = nn;
                                NodoTuL = Filetesto(AAA+3,1);
                                SensoriTuL(sen,1) = NodoTuL;
                                CatenaTuL(sen,1) = chainID(nn,4);
                                colCIR = colCIR+1;
                            end
                            if PCL > 0 && Cir > 0
                                figure(37)
                                ylabel('Displacement [mm]');
                                xlabel('Date [dd/mm/yyyy]');
                                set(gca,'YColor','k')
                                title('Correlation between corresponding sensors');
                                grid on
                                hold on
                                dim1 = find(GI_Z_PCL(:,PCL));
                                dim2 = find(GI_Z_TuL(:,colCIR));
                                if isempty(dim1) == 0 && isempty(dim2) == 0
                                    plot(GI_Date_PCL(1:dim1(end),PCL),GI_Z_PCL(1:dim1(end),PCL));
                                    GI_TuLvsPCL = plot(GI_Date_TuL(1:dim2(end),Cir),GI_Z_TuL(1:dim2(end),colCIR));
                                    MIN1 = min(GI_Z_PCL(:,PCL));
                                    MIN2 = min(GI_Z_TuL(:,colCIR));
                                    MIN = min(MIN1,MIN2);
                                    MAX1 = max(GI_Z_PCL(:,PCL));
                                    MAX2 = max(GI_Z_TuL(:,colCIR));
                                    MAX = max(MAX1,MAX2);
                                    if MAX < 5 && MIN > -5 % mm
                                        ylim([-5 5]);
                                    elseif MAX < 5
                                        ylim([MIN-1 5]);
                                    elseif MIN > -5
                                        ylim([-5 MAX+1]);
                                    end
                                    datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                                    h = gca;
                                    h.XAxis.MinorTick = 'on';
                                    xtickangle(20);
                                    str(1,1) = cellstr([char(CatenaPCL(sen,1)) ' Node ' num2str(NodoPCL) '']);
                                    str(1,2) = cellstr([char(CatenaTuL(sen,1)) ' Node ' num2str(NodoTuL) '']);
                                    legend(str,'Location','northwest');
                                    TempName = char(strcat('Report',siteID,'-PCLvsTuL',num2str(num),'_ENG.png'));
                                    saveas(GI_TuLvsPCL,TempName);
                                    num = num+1;
                                end
                                close(figure(37));
                                sen = sen+1;
                                AAA = AAA+4;
                                break
                            end
                        end
                    end
                end
                num = num-1;
                if num ~= 0 % Non ci sono legami
                    add(Site_ENG,sezGrafTuLvsPCL_ENG);
                    add(Site_ENG,testoTuLvsPCL);
                    if num == 1
                        TempName = char(strcat('Report',siteID,'-PCLvsTuL',num2str(num),'_ENG.png'));
                        Chart1_ENG = Image(TempName);
                        Chart1_ENG.Style = {ScaleToFit};
                        add(Site_ENG,Chart1_ENG);
                    else
                        n = 1;
                        while n <= num
                            TempName = char(strcat('Report',siteID,'-PCLvsTuL',num2str(n),'_ENG.png'));
                            Chart1_ENG = Image(TempName);
                            Chart1_ENG.Style = {Height('7cm')};
                            if n+1 <= num
                                TempName = char(strcat('Report',siteID,'-PCLvsTuL',num2str(n+1),'_ENG.png'));
                                Chart2_ENG = Image(TempName);
                                Chart2_ENG.Style = {Height('7cm')};
                                lot = Table({Chart1_ENG, Chart2_ENG});
                                lot.Style = {ResizeToFitContents(false), Width('100%')};
                                n = n+2;
                                add(Site_ENG,lot);
                            else
                                n = n+1;
                                add(Site_ENG,Chart1_ENG);
                            end
                        end
                    end
                    ChartPCLvsTuL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison between '...
                    'local displacements recorded during the reference time period by the '...
                    'Cir Array sensor installed on the upper part of '...
                    'the tunnel section, and the corresponding PreConv Array sensor']);
                    FIG_ENG = FIG_ENG+1;
                    ChartPCLvsTuL_ENG_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                    add(Site_ENG,ChartPCLvsTuL_ENG_cap);
                    
                    text = 'Dsiplacement data refer to the sensors listed below: ';
                    testoPCLvsTuL2 = Paragraph(text);
                    testoPCLvsTuL2.HAlign = 'justify';
                    add(Site,testoPCLvsTuL2);
                    I = size(SensoriPCL);
                    for a = 1:I(1)
                        textPC = ['- PreConv Array ' char(CatenaPCL(a,1)) ' - Node ' num2str(SensoriPCL(a,1)) ';'];
                        textCA = ['- Cir Array ' char(CatenaTuL(a,1)),' - Node ' num2str(SensoriTuL(a,1)) '.'];
                        spazio = Paragraph('');
                        testoPCLvsTuL2 = Paragraph(textPC);
                        testoPCLvsTuL3 = Paragraph(textCA);
                        add(Site_ENG,testoPCLvsTuL2);
                        add(Site_ENG,testoPCLvsTuL3);
                        add(Site_ENG,spazio);
                    end
                    add(Site_ENG,br);
                end
            end
        end
    end
    
    % ---> Grafici spostamento Cir vs Rad
    if sum(rRaL) > 0 && exist('GI_dS_RL_TuL','var') && sum(rRaL) > 0 && exist('GI_dS_TuL_RL','var')
        if isempty(GI_dS_RL_TuL) == 0 && isempty(GI_dS_TuL_RL) == 0
            sezGrafTuLvsRL = Heading2('Correlazioni tra Cir Array e Rad Array');
            sezGrafTuLvsRL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            testoTuLvsRL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                'evidenziare eventuali correlazioni presenti tra l''andamento nel tempo '...
                'della risultante degli spostamenti 2D differenziali locali registrati '...
                'dal sensore Radial Link prossimo alla sezione monitorata e dal '...
                'corrispondente sensore Tunnel Link.']);
            testoTuLvsRL.HAlign = 'justify';
            
            % Cerco eventuali correlazioni con Cir Array
            NomeFile = strcat('Report',siteID,'-TuLvsRL.txt');
            Filetesto = importdata(NomeFile);
            [rF,~] = size(Filetesto);
            AAA = 1;
            num = 1;
            sen = 1;
            SensoriTuL = zeros(1,1);
            SensoriRL = zeros(1,1);
            CatenaTuL = cell(1,1);
            CatenaRL = cell(1,1);
            colCIR = 0;
            while AAA < rF 
                  Rad = 0;
                  Cir = 0;
                  check1 = Filetesto(AAA,1);
                  if check1 == 99999 % Non ci sono Rad Array o non ci sono Cir
                      break
                  else
                      check2 = Filetesto(AAA+1,1);
                      for nn = 1:rAR
                          chain = char(chainID(nn,4));
                          if check1 == str2num(chain(end-2:end)) % Il primo deve sempre essere il Cir
                              Cir = nn;
                              NodoTuL = Filetesto(AAA+2,1);
                              SensoriTuL(sen,1) = NodoTuL;
                              CatenaTuL(sen,1) = chainID(nn,4);
                              colCIR = colCIR+1;
                          end
                          if check2 == str2num(chain(end-2:end))
                              Rad = nn;
                              NodoRL = Filetesto(AAA+3,1);
                              SensoriRL(sen,1) = NodoRL;
                              CatenaRL(sen,1) = chainID(nn,4);
                          end
                          if Rad > 0 && Cir > 0
                              figure(28)
                              ylabel('Spostamento [mm]');
                              xlabel('Data [gg/mm/aaaa]');
                              set(gca,'YColor','k')
                              title('Correlazione fra gli spostamenti corrispondenti');
                              grid on
                              hold on
                              dim1 = find(GI_dS_RL_TuL(:,Rad));
                              dim2 = find(GI_dS_TuL_RL(:,colCIR));
                              if isempty(dim1) == 0 && isempty(dim2) == 0
                                  plot(GI_Date_Rad(1:dim1(end),Rad),GI_dS_RL_TuL(1:dim1(end),Rad));
                                  GI_TuLvsRL = plot(GI_Date_TuL(1:dim2(end),Cir),GI_dS_TuL_RL(1:dim2(end),colCIR));
                                  MAX1 = max(GI_dS_RL_TuL(:,Rad));
                                  MAX2 = max(GI_dS_TuL_RL(:,colCIR));
                                  MAX = max(MAX1,MAX2);
                                  if MAX < 5 % mm
                                      ylim([0 5]);
                                  end
                                  datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                                  h = gca;
                                  h.XAxis.MinorTick = 'on';
                                  xtickangle(20);
                                  str(1,1) = cellstr([char(CatenaTuL(sen,1)) ' Nodo ' num2str(NodoTuL) '']);
                                  str(1,2) = cellstr([char(CatenaRL(sen,1)) ' Nodo ' num2str(NodoRL) '']);
                                  legend(str,'Location','northwest');
                                  TempName = char(strcat('Report',siteID,'-TuLvsRL',num2str(num),'.png'));
                                  saveas(GI_TuLvsRL,TempName);
                                  num = num+1;
                              end
                              close(figure(28));
                              sen = sen+1;
                              AAA = AAA+4;
                              break
                          end
                      end
                  end
            end
            num = num-1;
            if num ~= 0 % Non ci sono legami
                add(Site,sezGrafTuLvsRL);
                add(Site,testoTuLvsRL);
                if num == 1
                    TempName = char(strcat('Report',siteID,'-TuLvsRL',num2str(num),'.png'));
                    Chart1 = Image(TempName);
                    Chart1.Style = {ScaleToFit};
                    add(Site,Chart1);
                else
                    n = 1;
                    while n <= num
                        TempName = char(strcat('Report',siteID,'-TuLvsRL',num2str(n),'.png'));
                        Chart1 = Image(TempName);
                        Chart1.Style = {Height('7cm')};
                        if n+1 <= num
                            TempName = char(strcat('Report',siteID,'-TuLvsRL',num2str(n+1),'.png'));
                            Chart2 = Image(TempName);
                            Chart2.Style = {Height('7cm')};
                            lot = Table({Chart1, Chart2});
                            lot.Style = {ResizeToFitContents(false), Width('100%')};
                            n = n+2;
                            add(Site,lot);
                        else
                            n = n+1;
                            add(Site,Chart1);
                        end
                    end
                end
                ChartTuLvsRL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                    'relativo al periodo temporale di riferimento, tra i dati di '...
                    'spostamento locale 2D registrati dal nodo '...
                    'del Cir Array installato nella sezione ed il corrispondente '...
                    'sensore Radial Link pi' char(249) ' in prossimit' char(224) '']);
                FIG = FIG+1;
                ChartTuLvsRL_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                add(Site,ChartTuLvsRL_cap);
                
                text = 'Gli spostamenti sono riferiti alle misure dei sensori riportati di seguito: ';
                testoTuL2vsRL = Paragraph(text);
                testoTuL2vsRL.HAlign = 'justify';
                add(Site,testoTuL2vsRL);
                I = size(SensoriRL);
                for a = 1:I(1)
                    text = ['- Rad Array ' char(CatenaRL(a,1)) ' - Nodo numero ' num2str(SensoriRL(a,1)) ...
                        ', Cir Array ' char(CatenaTuL(a,1)),' - Nodo numero ' num2str(SensoriTuL(a,1)) ''];
                    testoTuL2vsRL = Paragraph(text);
                    add(Site,testoTuL2vsRL);
                end
                add(Site,br);
            end
            
            % --- ENG ---
            if activeEN == 1
                sezGrafTuLvsRL_ENG = Heading2('Correlation between Cir Array and Rad Array');
                sezGrafTuLvsRL_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
                testoTuLvsRL = Paragraph(['The following graph aims to highlight the presence of '...
                'correlations between 2D local differential displacements recorded by the Radial Link '...
                'located closer to the monitored section, and the corresponding Tunnel Link sensor.']);
                testoTuLvsRL.HAlign = 'justify';
                
                % Cerco eventuali correlazioni con Cir Array
                NomeFile = strcat('Report',siteID,'-TuLvsRL.txt');
                Filetesto = importdata(NomeFile);
                [rF,~] = size(Filetesto);
                AAA = 1;
                num = 1;
                sen = 1;
                SensoriTuL = zeros(1,1);
                SensoriRL = zeros(1,1);
                CatenaTuL = cell(1,1);
                CatenaRL = cell(1,1);
                colCIR = 0;
                while AAA < rF
                    Rad = 0;
                    Cir = 0;
                    check1 = Filetesto(AAA,1);
                    if check1 == 99999 % Non ci sono Rad Array o non ci sono Cir
                        break
                    else
                        check2 = Filetesto(AAA+1,1);
                        for nn = 1:rAR
                            chain = char(chainID(nn,4));
                            if check1 == str2num(chain(end-2:end)) % Il primo deve sempre essere il Cir
                                Cir = nn;
                                NodoTuL = Filetesto(AAA+2,1);
                                SensoriTuL(sen,1) = NodoTuL;
                                CatenaTuL(sen,1) = chainID(nn,4);
                                colCIR = colCIR+1;
                            end
                            if check2 == str2num(chain(end-2:end))
                                Rad = nn;
                                NodoRL = Filetesto(AAA+3,1);
                                SensoriRL(sen,1) = NodoRL;
                                CatenaRL(sen,1) = chainID(nn,4);
                            end
                            if Rad > 0 && Cir > 0
                                figure(38)
                                ylabel('Displacement [mm]');
                                xlabel('Date [dd/mm/yyyy]');
                                set(gca,'YColor','k')
                                title('Correlation between corresponding sensors');
                                grid on
                                hold on
                                dim1 = find(GI_dS_RL_TuL(:,Rad));
                                dim2 = find(GI_dS_TuL_RL(:,colCIR));
                                if isempty(dim1) == 0 && isempty(dim2) == 0
                                    plot(GI_Date_Rad(1:dim1(end),Rad),GI_dS_RL_TuL(1:dim1(end),Rad));
                                    GI_TuLvsRL = plot(GI_Date_TuL(1:dim2(end),Cir),GI_dS_TuL_RL(1:dim2(end),colCIR));
                                    MAX1 = max(GI_dS_RL_TuL(:,Rad));
                                    MAX2 = max(GI_dS_TuL_RL(:,colCIR));
                                    MAX = max(MAX1,MAX2);
                                    if MAX < 5 % mm
                                        ylim([0 5]);
                                    end
                                    datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                                    h = gca;
                                    h.XAxis.MinorTick = 'on';
                                    xtickangle(20);
                                    str(1,1) = cellstr([char(CatenaTuL(sen,1)) ' Node ' num2str(NodoTuL) '']);
                                    str(1,2) = cellstr([char(CatenaRL(sen,1)) ' Node ' num2str(NodoRL) '']);
                                    legend(str,'Location','northwest');
                                    TempName = char(strcat('Report',siteID,'-TuLvsRL',num2str(num),'_ENG.png'));
                                    saveas(GI_TuLvsRL,TempName);
                                    num = num+1;
                                end
                                close(figure(38));
                                sen = sen+1;
                                AAA = AAA+4;
                                break
                            end
                        end
                    end
                end
                num = num-1;
                if num ~= 0 % Non ci sono legami
                    add(Site_ENG,sezGrafTuLvsRL_ENG);
                    add(Site_ENG,testoTuLvsRL);
                    if num == 1
                        TempName = char(strcat('Report',siteID,'-TuLvsRL',num2str(num),'_ENG.png'));
                        Chart1_ENG = Image(TempName);
                        Chart1_ENG.Style = {ScaleToFit};
                        add(Site_ENG,Chart1_ENG);
                    else
                        n = 1;
                        while n <= num
                            TempName = char(strcat('Report',siteID,'-TuLvsRL',num2str(n),'_ENG.png'));
                            Chart1_ENG = Image(TempName);
                            Chart1_ENG.Style = {Height('7cm')};
                            if n+1 <= num
                                TempName = char(strcat('Report',siteID,'-TuLvsRL',num2str(n+1),'_ENG.png'));
                                Chart2_ENG = Image(TempName);
                                Chart2_ENG.Style = {Height('7cm')};
                                lot = Table({Chart1_ENG, Chart2_ENG});
                                lot.Style = {ResizeToFitContents(false), Width('100%')};
                                n = n+2;
                                add(Site_ENG,lot);
                            else
                                n = n+1;
                                add(Site_ENG,Chart1_ENG);
                            end
                        end
                    end
                    ChartTuLvsRL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison '...
                    'between 2D local displacement data recorded by the Radial Link sensor closer to '...
                    'the monitored section, and the corresponding Tunnel Link sensor']);
                    FIG_ENG = FIG_ENG+1;
                    ChartTuLvsRL_ENG_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                    add(Site_ENG,ChartTuLvsRL_ENG_cap);
                    
                    text = 'Displacement data refer to the sensors listed below: ';
                    testoTuL2vsRL = Paragraph(text);
                    testoTuL2vsRL.HAlign = 'justify';
                    add(Site_ENG,testoTuL2vsRL);
                    I = size(SensoriRL);
                    for a = 1:I(1)
                        text = ['- Rad Array ' char(CatenaRL(a,1)) ' - Node ' num2str(SensoriRL(a,1)) ...
                            ', Cir Array ' char(CatenaTuL(a,1)),' - Node ' num2str(SensoriTuL(a,1)) ''];
                        testoTuL2vsRL = Paragraph(text);
                        add(Site_ENG,testoTuL2vsRL);
                    end
                    add(Site_ENG,br);
                end
            end
        end
    end
    
    % ---> Grafici spostamento Rad vs MPB
    if sum(rRaL) > 0 && exist('GI_dS_RL_MPB','var') && sum(rMPBEL) > 0 && exist('GI_dS_MPB_RL','var')
        if isempty(GI_dS_RL_MPB) == 0 && isempty(GI_dS_MPB_RL) == 0
            sezGrafMPBvsRL = Heading2('Correlazioni tra Rad Array ed estensimetro multibase');
            sezGrafMPBvsRL.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            testoMPBvsRL = Paragraph(['Il grafico seguente ha l''obiettivo di '...
                'evidenziare eventuali correlazioni presenti tra l''andamento nel tempo '...
                'della risultante degli spostamenti 3D differenziali locali registrati '...
                'dal sensore Radial Link e la relativa deformazione radiale misurata '...
                'dalla base pi' char(250) ' lunga dell''estensimetro multibase.']);
            testoMPBvsRL.HAlign = 'justify';
            
            % Cerco eventuali correlazioni con  Estensimetro multibase
            NomeFile = strcat('Report',siteID,'-RLvsMPBEL.txt');
            Filetesto = importdata(NomeFile);
            [rF,~] = size(Filetesto);
            AAA = 1;
            num = 1;
            sen = 1;
            SensoriRL = zeros(1,1);
            SensoriMPB = zeros(1,1);
            CatenaRL = cell(1,1);
            CatenaMPB = cell(1,1);
            colMPB = 0;
            while AAA < rF
                Rad = 0;
                MPB = 0;
                check1 = Filetesto(AAA,1);
                if check1 == 99999 % Non ci sono Rad Array o estensimetri multibase
                    break
                else
                    check2 = Filetesto(AAA+1,1);
                    for nn = 1:rAR
                        chain = char(chainID(nn,4));
                        if check1 == str2num(chain(end-2:end)) % Il primo deve sempre essere il Rad
                            Rad = nn;
                            NodoRL = Filetesto(AAA+2,1);
                            SensoriRL(sen,1) = NodoRL;
                            CatenaRL(sen,1) = chainID(nn,4);
                        end
                        if check2 == str2num(chain(end-2:end))
                            MPB = nn;
                            NodoMPB = Filetesto(AAA+3,1);
                            SensoriMPB(sen,1) = NodoMPB;
                            CatenaMPB(sen,1) = chainID(nn,4);
                            colMPB = colMPB+1;
                        end
                        if Rad > 0 && MPB > 0
                            figure(29)
                            ylabel('Spostamento [mm]');
                            xlabel('Data [gg/mm/aaaa]');
                            set(gca,'YColor','k')
                            title('Correlazione fra gli spostamenti corrispondenti');
                            grid on
                            hold on
                            dim1 = find(GI_dS_RL_MPB(:,Rad));
                            dim2 = find(GI_dS_MPB_RL(:,colMPB));
                            if isempty(dim1) == 0 && isempty(dim2) == 0
                                plot(GI_Date_Rad(1:dim1(end),Rad),GI_dS_RL_MPB(1:dim1(end),Rad));
                                GI_MPBvsRL = plot(GI_Date_MPB(1:dim2(end),MPB),GI_dS_MPB_RL(1:dim2(end),colMPB));
                                MAX1 = max(GI_dS_RL_MPB(:,Rad));
                                MAX2 = max(GI_dS_MPB_RL(:,colMPB));
                                MAX = max(MAX1,MAX2);
                                if MAX < 5 % mm
                                    ylim([-5 5]);
                                end
                                datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                                h = gca;
                                h.XAxis.MinorTick = 'on';
                                xtickangle(20);
                                str(1,1) = cellstr([char(CatenaRL(sen,1)) ' Nodo ' num2str(NodoRL) '']);
                                str(1,2) = cellstr([char(CatenaMPB(sen,1)) ' Estensimetro ' num2str(NodoMPB) '']);
                                legend(str,'Location','northwest');
                                TempName = char(strcat('Report',siteID,'-RLvsMPB',num2str(num),'.png'));
                                saveas(GI_MPBvsRL,TempName);
                                num = num+1;
                            end
                            close(figure(29))
                            sen = sen+1;
                            AAA = AAA+4;
                            break
                        end
                    end
                end
            end
            num = num-1;
            if num ~= 0 % Non ci sono legami
                add(Site,sezGrafMPBvsRL);
                add(Site,testoMPBvsRL);
                if num == 1
                    TempName = char(strcat('Report',siteID,'-RLvsMPB',num2str(num),'.png'));
                    Chart1 = Image(TempName);
                    Chart1.Style = {ScaleToFit};
                    add(Site,Chart1);
                else
                    n = 1;
                    while n <= num
                        TempName = char(strcat('Report',siteID,'-RLvsMPB',num2str(n),'.png'));
                        Chart1 = Image(TempName);
                        Chart1.Style = {Height('7cm')};
                        if n+1 <= num
                            TempName = char(strcat('Report',siteID,'-RLvsMPB',num2str(n+1),'.png'));
                            Chart2 = Image(TempName);
                            Chart2.Style = {Height('7cm')};
                            lot = Table({Chart1, Chart2});
                            lot.Style = {ResizeToFitContents(false), Width('100%')};
                            n = n+2;
                            add(Site,lot);
                        else
                            n = n+1;
                            add(Site,Chart1);
                        end
                    end
                end
                ChartMPBvsRL_cap = Paragraph(['Fig. ' num2str(FIG) ' - Confronto '...
                    'relativo al periodo temporale di riferimento, tra i dati di '...
                    'spostamento locale 3D registrati dal nodo Radial Link pi' char(249) ...
                    ' in prossimit' char(224) ' della sezione e la base pi' char(249) ...
                    ' lunga dell''estensimetro multibase']);
                FIG = FIG+1;
                ChartMPBvsRL_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                add(Site,ChartMPBvsRL_cap);
                
                text = 'Gli spostamenti sono riferiti alle misure dei sensori riportati di seguito: ';
                testoMPB2vsRL = Paragraph(text);
                testoMPB2vsRL.HAlign = 'justify';
                add(Site,testoMPB2vsRL);
                I = size(SensoriRL);
                for a = 1:I(1)
                    text = ['- Rad Array ' char(CatenaRL(a,1)) ' - Nodo numero ' num2str(SensoriRL(a,1)) ...
                        ', Analog Array ' char(CatenaMPB(a,1)),' - Estensimetro Multibase numero ' num2str(SensoriMPB(a,1)) ''];
                    testoMPB2vsRL = Paragraph(text);
                    add(Site,testoMPB2vsRL);
                end
                
                add(Site,br);
            end
            
            %--- ENG ---
            if activeEN == 1
                sezGrafMPBvsRL_ENG = Heading2('Correlation between Rad Array and Multipoint Borehole Extensometer (MPBE)');
                sezGrafMPBvsRL_ENG.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
                testoMPBvsRL = Paragraph(['The following graph aims to highlight the presence of correlations '...
                'between 3D local differential displacements recorded by the Radial Link sensor, and the '...
                'corresponding radial deformation measured by the longest rod of the MPBE.']);
                testoMPBvsRL.HAlign = 'justify';
                
                % Cerco eventuali correlazioni con  Estensimetro multibase
                NomeFile = strcat('Report',siteID,'-RLvsMPBEL.txt');
                Filetesto = importdata(NomeFile);
                [rF,~] = size(Filetesto);
                AAA = 1;
                num = 1;
                sen = 1;
                SensoriRL = zeros(1,1);
                SensoriMPB = zeros(1,1);
                CatenaRL = cell(1,1);
                CatenaMPB = cell(1,1);
                colMPB = 0;
                while AAA < rF
                    Rad = 0;
                    MPB = 0;
                    check1 = Filetesto(AAA,1);
                    if check1 == 99999 % Non ci sono Rad Array o estensimetri multibase
                        break
                    else
                        check2 = Filetesto(AAA+1,1);
                        for nn = 1:rAR
                            chain = char(chainID(nn,4));
                            if check1 == str2num(chain(end-2:end)) % Il primo deve sempre essere il Rad
                                Rad = nn;
                                NodoRL = Filetesto(AAA+2,1);
                                SensoriRL(sen,1) = NodoRL;
                                CatenaRL(sen,1) = chainID(nn,4);
                            end
                            if check2 == str2num(chain(end-2:end))
                                MPB = nn;
                                NodoMPB = Filetesto(AAA+3,1);
                                SensoriMPB(sen,1) = NodoMPB;
                                CatenaMPB(sen,1) = chainID(nn,4);
                                colMPB = colMPB+1;
                            end
                            if Rad > 0 && MPB > 0
                                figure(39)
                                ylabel('Displacement [mm]');
                                xlabel('Date [d/mm/yyyy]');
                                set(gca,'YColor','k')
                                title('Correlation between corresponding sensors');
                                grid on
                                hold on
                                dim1 = find(GI_dS_RL_MPB(:,Rad));
                                dim2 = find(GI_dS_MPB_RL(:,colMPB));
                                if isempty(dim1) == 0 && isempty(dim2) == 0
                                    plot(GI_Date_Rad(1:dim1(end),Rad),GI_dS_RL_MPB(1:dim1(end),Rad));
                                    GI_MPBvsRL = plot(GI_Date_MPB(1:dim2(end),MPB),GI_dS_MPB_RL(1:dim2(end),colMPB));
                                    MAX1 = max(GI_dS_RL_MPB(:,Rad));
                                    MAX2 = max(GI_dS_MPB_RL(:,colMPB));
                                    MAX = max(MAX1,MAX2);
                                    if MAX < 5 % mm
                                        ylim([-5 5]);
                                    end
                                    datetick('x','dd/mm/yyyy','keepticks','keeplimits');
                                    h = gca;
                                    h.XAxis.MinorTick = 'on';
                                    xtickangle(20);
                                    str(1,1) = cellstr([char(CatenaRL(sen,1)) ' Node ' num2str(NodoRL) '']);
                                    str(1,2) = cellstr([char(CatenaMPB(sen,1)) ' Extensometer ' num2str(NodoMPB) '']);
                                    legend(str,'Location','northwest');
                                    TempName = char(strcat('Report',siteID,'-RLvsMPB',num2str(num),'_ENG.png'));
                                    saveas(GI_MPBvsRL,TempName);
                                    num = num+1;
                                end
                                close(figure(39))
                                sen = sen+1;
                                AAA = AAA+4;
                                break
                            end
                        end
                    end
                end
                num = num-1;
                if num ~= 0 % Non ci sono legami
                    add(Site_ENG,sezGrafMPBvsRL_ENG);
                    add(Site_ENG,testoMPBvsRL);
                    if num == 1
                        TempName = char(strcat('Report',siteID,'-RLvsMPB',num2str(num),'_ENG.png'));
                        Chart1_ENG = Image(TempName);
                        Chart1_ENG.Style = {ScaleToFit};
                        add(Site_ENG,Chart1_ENG);
                    else
                        n = 1;
                        while n <= num
                            TempName = char(strcat('Report',siteID,'-RLvsMPB',num2str(n),'_ENG.png'));
                            Chart1_ENG = Image(TempName);
                            Chart1_ENG.Style = {Height('7cm')};
                            if n+1 <= num
                                TempName = char(strcat('Report',siteID,'-RLvsMPB',num2str(n+1),'_ENG.png'));
                                Chart2_ENG = Image(TempName);
                                Chart2_ENG.Style = {Height('7cm')};
                                lot = Table({Chart1_ENG, Chart2_ENG});
                                lot.Style = {ResizeToFitContents(false), Width('100%')};
                                n = n+2;
                                add(Site_ENG,lot);
                            else
                                n = n+1;
                                add(Site_ENG,Chart1_ENG);
                            end
                        end
                    end
                    ChartMPBvsRL_ENG_cap = Paragraph(['Fig. ' num2str(FIG_ENG) ' - Comparison '...
                    'between 3D local differential displacements recorded by the Radial Link sensor, and the '...
                    'corresponding radial deformation measured by the longest rod of the MPBE.']);
                    FIG_ENG = FIG_ENG+1;
                    ChartMPBvsRL_ENG_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                    add(Site_ENG,ChartMPBvsRL_ENG_cap);
                    
                    text = 'Displacement data refer to the sensors listed below: ';
                    testoMPB2vsRL = Paragraph(text);
                    testoMPB2vsRL.HAlign = 'justify';
                    add(Site_ENG,testoMPB2vsRL);
                    I = size(SensoriRL);
                    for a = 1:I(1)
                        text = ['- Rad Array ' char(CatenaRL(a,1)) ' - Node ' num2str(SensoriRL(a,1)) ...
                            ', Analog Array ' char(CatenaMPB(a,1)),' - MPBE ' num2str(SensoriMPB(a,1)) ''];
                        testoMPB2vsRL = Paragraph(text);
                        add(Site_ENG,testoMPB2vsRL);
                    end
                    
                    add(Site_ENG,br);
                end
            end
        end
    end
end

text = 'report_CrossGraphs function executed correctly. report_CrossGraphs function closed';
fprintf(fileID,fmt,text);
fclose(fileID);

end