function [GI_Rad_XYZ,GI_Rad_Num,GI_Rad_MPBEL,GI_Rad_Cir,GI_Rad_Date,ATTIVA,FIG] = report_RaL_ENG(...
    DTcatena,rRaL,m,NodoRadialLink,toolrif,unitrif,datarif,firstdata_num,Font_caption,...
    Font_tools,siteID,DT,FIG,br,colonna2,colonna2bis,status,ATTIVA,conn,FileName)

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

% Make sure DOM is compilable
makeDOMCompilable()

GI_Rad_XYZ = [];
GI_Rad_Num = [];
GI_Rad_MPBEL = [];
GI_Rad_Cir = [];
GI_Rad_Date = [];

check = 0;
while check == 0
    if status(m,1) == 1
        if ATTIVA == 1
            ATTIVA = 0;
        testo = Paragraph('Array not installed or inactive.');
            add(DT,testo);
        end
        check = 1;
    elseif status(m,1) == 3
        if ATTIVA == 1
            ATTIVA = 0;
        testo = Paragraph(['Monitoring completed. Please log into the web-based platoform '...
            'to access the complete dataset.']);
            add(DT,testo);
        end
        check = 1;
    else
        NODATA(m,1) = 0;
        date = datestr(datenum(colonna2{m+1,1},'dd-mm-yyyy'),'yyyy-mm-dd'); % data riferimento definita sul sito
        % posizione di progetto dei nodi
        comando = ['select EventDate, EventTime, X, Y, Z from ElabDataView where EventDate = ''' ...
            date ''' and  ToolNameID = ''' char(toolrif) ''' and UnitName = ''' char(unitrif) ...
            ''' '];
        curs = exec(conn,comando);
        curs = fetch(curs);
        SezioneXYZ = curs.Data;
        Datasez = SezioneXYZ(1,1);
        Orasez = SezioneXYZ(1,2);
        [rz,~] = size(SezioneXYZ);
        scrivi = 1;
        for rr = 1:rz
            if strcmp(SezioneXYZ(rr,1),Datasez)==1 && strcmp(SezioneXYZ(rr,2),Orasez) ==1
                CoordX(scrivi,1) = cell2mat(SezioneXYZ(rr,3));
                CoordY(scrivi,1) = cell2mat(SezioneXYZ(rr,4));
                CoordZ(scrivi,1) = cell2mat(SezioneXYZ(rr,5));
                scrivi = scrivi+1;
            end
        end
        
        diffX = zeros(1,rRaL(m,1));
        diffY = zeros(1,rRaL(m,1));
        diffZ = zeros(1,rRaL(m,1));
        RIS_XYZ_Mese = zeros(1,rRaL(m,1));
        RIS_XYZ_Tot = zeros(1,rRaL(m,1));
        Num = zeros(rRaL(m,1),1);
        for n = 1:rRaL(m,1)
            NodeNum = num2str(NodoRadialLink(n,m));
            % dati del mese
            comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z '...
                'from ElabDataView where EventDate >= ''' datarif ''' and  ToolNameID = ''' ...
                char(toolrif) ''' and UnitName = ''' char(unitrif) ''' and NodeNum = ''' NodeNum ''' '];
            curs = exec(conn,comando);
            curs = fetch(curs);
            Dati = curs.Data;
            Num(n,1) = NodoRadialLink(n,m);
                                    
            [rD,rC] = size(Dati);
            if rC ~= 1
                T = [cell2mat(Dati(:,1)) repmat(' ', [rD,1]) cell2mat(Dati(:,2))];
                Date = datenum(T); % Data
                if n == 1 % Il primo lo scrivo e creo la variabile di controllo
                else
                    [rS,~] = size(asseX);
                    if rD ~= rS
                        NODATA(m,1) = 1;
                        check = 0;
                        break
                    else
                        check = 1;
                    end
                end
                                
                % spostamenti dei nodi dall'inizio
                asseX(:,n) = cell2mat(Dati(:,3));
                asseY(:,n) = cell2mat(Dati(:,4));
                asseZ(:,n) = cell2mat(Dati(:,5));
                X_RL_Tot(:,n) = cell2mat(Dati(:,6));
                Y_RL_Tot(:,n) = cell2mat(Dati(:,7));
                Z_RL_Tot(:,n) = cell2mat(Dati(:,8));
                X_RL_Mese(:,n) = X_RL_Tot(:,n)-X_RL_Tot(1,n)+CoordX(n,1)';
                Y_RL_Mese(:,n) = Y_RL_Tot(:,n)-Y_RL_Tot(1,n)+CoordY(n,1)';
                Z_RL_Mese(:,n) = Z_RL_Tot(:,n)-Z_RL_Tot(1,n)+CoordZ(n,1)';
                diffX(1,n) = asseX(end,n)-asseX(1,n);
                diffY(1,n) = asseY(end,n)-asseY(1,n);
                diffZ(1,n) = asseZ(end,n)-asseZ(1,n);
                dX(:,n) = asseX(:,n)-asseX(:,1);
                dY(:,n) = asseY(:,n)-asseY(:,1);
                dZ(:,n) = asseZ(:,n)-asseZ(:,1);
                                
                RIS_XYZ_Mese(1,n) = (sqrt(diffX(1,n)^2 + diffY(1,n)^2+diffZ(1,n)^2))*1000;
                cX_Mese(1,n) = 100*abs(1000*diffX(1,n))/RIS_XYZ_Mese(1,n);
                cY_Mese(1,n) = 100*abs(1000*diffY(1,n))/RIS_XYZ_Mese(1,n);
                cZ_Mese(1,n) = 100*abs(1000*diffZ(1,n))/RIS_XYZ_Mese(1,n);
                RIS_XYZ_Tot(1,n) = (sqrt(asseX(end,n)^2 + asseY(end,n)^2+asseZ(end,n)^2))*1000;
                cX_Tot(1,n) = 100*abs(1000*asseX(1,n))/RIS_XYZ_Tot(1,n);
                sigX_Tot(1,n) = sign(asseX(1,n));
                cY_Tot(1,n) = 100*abs(1000*asseY(1,n))/RIS_XYZ_Tot(1,n);
                sigY_Tot(1,n) = sign(asseY(1,n));
                cZ_Tot(1,n) = 100*abs(1000*asseZ(1,n))/RIS_XYZ_Tot(1,n);
                sigZ_Tot(1,n) = sign(asseZ(1,n));
            else
                NODATA(m,1) = 1;
                check = 1;
            end
        end
        
        if NODATA(m,1) == 0
            if strcmp(colonna2bis(m+1,1),colonna2(m+1,1)) == 0 % data zero diversa data riferimento
                clear RIS_XYZ_Tot
                datarifNEW = datestr(firstdata_num{m+1,1},'yyyy-mm-dd'); % data riferimento definita sul sito
                for nw = 1:rRaL(m,1)
                    NodeNum = num2str(NodoRadialLink(nw,m));
                    comando = ['select EventDate, EventTime, XShift, YShift, ZShift, X, Y, Z, '...
                        'from ElabDataView where EventDate = ''' datarifNEW ''' and  ToolNameID = ''' char(toolrif) ...
                        ''' and UnitName = ''' char(unitrif) ''' and NodeNum = ''' NodeNum ''' '];
                    curs = exec(conn,comando);
                    curs = fetch(curs);
                    DatiNEW = curs.Data; % dati registrati alla data di riferimento
                    Num(nw,1) = NodoRadialLink(nw,m);
                    [~,rC] = size(DatiNEW);
                    if rC ~= 1
                        % dalla data di riferimento
                         asseX(:,nw) = asseX(:,nw)-cell2mat(DatiNEW(1,3));
                         asseY(:,nw) = asseY(:,nw)-cell2mat(DatiNEW(1,4));
                         asseZ(:,nw) = asseZ(:,nw)-cell2mat(DatiNEW(1,5));
                         X_RL_Tot(:,nw) = X_RL_Tot-cell2mat(DatiNEW(:,6))+CoordX(nw,1)';
                         Y_RL_Tot(:,nw) = Y_RL_Tot-cell2mat(DatiNEW(:,7))+CoordY(nw,1)';
                         Z_RL_Tot(:,nw) = Z_RL_Tot-cell2mat(DatiNEW(:,8))+CoordZ(nw,1)';                         
                         RIS_XYZ_Tot(1,n) = (sqrt(asseX(end,n)^2 + asseY(end,n)^2+asseZ(end,n)^2))*1000;
                         cX_Tot(1,n) = 100*abs(1000*diffX(1,n))/RIS_XYZ_Tot(1,n);
                         cY_Tot(1,n) = 100*abs(1000*diffY(1,n))/RIS_XYZ_Tot(1,n);
                         cZ_Tot(1,n) = 100*abs(1000*diffZ(1,n))/RIS_XYZ_Tot(1,n);
                    else
                        NODATA(m,1) = 1;
                    end
                end
            end
                   
            GI_Rad_XYZ = max(RIS_XYZ_Mese);
            ind = find(GI_Rad_XYZ==max(RIS_XYZ_Mese(1,:)));
            GI_Rad_Num = Num(ind(1));
            GI_Rad_Date = Date;
            
            % Cerco eventuali correlazioni con Multibase
            NomeFile = strcat('Report',siteID,'-RLvsMPBEL.txt');
            Filetesto = importdata(NomeFile);
            [rF,~] = size(Filetesto);
            AAA = 1;
            Var = 0;
            while AAA < rF 
                check1 = Filetesto(AAA,1);
                if check1 == 99999 
                   AAA = 2;
                else
                    check2 = Filetesto(AAA+1,1);
                    if check1 == str2num(DTcatena(end-2:end)) 
                       Nodo = Filetesto(AAA+2,1);
                       Var = 1;
                    elseif check2 == str2num(DTcatena(end-2:end))
                           Nodo = Filetesto(AAA+3,1);
                           Var = 1;
                    end
                    AAA = AAA+4;
                end
            end
            if Var == 1
                % Riabilitare le variabili sotto se vogliamo usare i
                % cumulati anzichè i locali
%                 sX = dX';
%                 sTX = cumsum(sX);
%                 sX = sTX';
%                 sY = dY';
%                 sTY = cumsum(sY);
%                 sY = sTY';
%                 sZ = dZ';
%                 sTZ = cumsum(sZ);
%                 sZ = sTZ';
               GI_Rad_MPBEL = (sqrt(dX(:,Nodo).^2 + dY(:,Nodo).^2 + dZ(:,Nodo).^2))*1000; % ad ogni rad è associato al massimo un solo multibase
            end
            
            % Cerco eventuali correlazioni con Cir
            NomeFile = strcat('Report',siteID,'-TuLvsRL.txt');
            Filetesto = importdata(NomeFile);
            [rF,~] = size(Filetesto);
            AAA = 1;
            Var = 0;
            while AAA < rF % Cerco coppie Cir - Rad
                check1 = Filetesto(AAA,1);
                if check1 == 99999 % Non ci sono Rad o non ci sono Cir
                   AAA = 2;
                else
                    check2 = Filetesto(AAA+1,1);
                    if check1 == str2num(DTcatena(end-2:end)) % Il Cir è da prendere in considerazione ed è riportato nella prima riga del file
                       Nodo = Filetesto(AAA+2,1);
                       Var = 1;
                    elseif check2 == str2num(DTcatena(end-2:end)) % Il Cir è da prendere in considerazione ed è riportato nella seconda riga del file
                           Nodo = Filetesto(AAA+3,1);
                           Var = 1;
                    end
                    AAA = AAA+4;
                end
            end
            if Var == 1
               GI_Rad_Cir = (sqrt(dX(:,Nodo).^2 + dZ(:,Nodo).^2))*1000; %Più rad possono associarsi allo stesso cir
            end
                        
           % Istogramma 3D displacements
            figure(1)
            [~,nn] = size(RIS_XYZ_Mese(end,:));
            for w = 1:nn
                nodi_grafico(1,w) = w;
            end
            RIS_XYZ = [RIS_XYZ_Mese(end,:)' RIS_XYZ_Tot(end,:)'];
            Rad_3D = barh(nodi_grafico,RIS_XYZ);
            title('3D Local displacements');
            xlabel('Displacement [mm]');
            ylabel('Node [-]');
            h = gca;
            h.XAxis.MinorTick = 'on';
            h.YAxis.MinorTick = 'off';
            Max(1) = max(RIS_XYZ_Mese);
            Max(2) = max(RIS_XYZ_Tot);
            MAX = max(Max);
            in = find(Max == MAX);
            if in == 1
                POS = find(RIS_XYZ_Mese == Max(1));
            else
                POS = find(RIS_XYZ_Tot == Max(2));
            end
            if MAX < 10 % mm
                xlim([0 10]);
            end
            yticks(0:1:nn);
            grid on
            if POS > rRaL(m)/2 % Legenda in basso a dx
                legend('Reference time period','Complete monitoring period','Location','southeast');
            else % legenda in alto a dx
                legend('Reference time period','Complete monitoring period','Location','northeast');
            end
            TempName = char(strcat('Report',siteID,'-', char(toolrif),'Rad3D_ENG.png'));
            saveas(Rad_3D(1),TempName);
            ChartRad = Image(TempName);
            ChartRad.Style = {HAlign('justify'),ScaleToFit};
            ChartRad_cap = Paragraph(['Fig. ' num2str(FIG) ' - 3D local differential '...
                'displacements recorded by the 3D MEMS sensor during the reference time period '...
                'and the complete monitoring period']);
            FIG = FIG+1;
            ChartRad_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};
                        
            % --- Sezione - MESE ---
            contaS_Mese = 1;
            conta0_Mese = 1;
            for ris = 1:nn
                if RIS_XYZ_Mese(end,ris)> 0.5
                    nodiSX(contaS_Mese,1) = CoordX(ris,1);
                    nodiSZ(contaS_Mese,1) = CoordZ(ris,1);
                    contaS_Mese = contaS_Mese+1;
                else
                    nodi0X(conta0_Mese,1) = CoordX(ris,1);
                    nodi0Z(conta0_Mese,1) = CoordZ(ris,1);
                    conta0_Mese = conta0_Mese+1;
                end
            end
            
            % Aggiungo ancora
            % --- Geometria Strumento - Mese ---
            figure(2)
            plot([0; CoordX(:,1)],[0;CoordZ(:,1)],'-','Color','black');
            hold on
            if contaS_Mese > 1
                sezC = plot(nodiSX(:,1),nodiSZ(:,1),'o','Color','red');
                set(sezC, 'markerfacecolor', get(sezC, 'color'));
            end
            hold on
            if conta0_Mese > 1
                sez0 = plot(nodi0X(:,1),nodi0Z(:,1),'o','Color','black');
                set(sez0, 'markerfacecolor', get(sez0, 'color'));
            end
            ancora = plot(0,0,'s','Color','black','MarkerSize' ,13);
            set(ancora, 'markerfacecolor', get(ancora, 'color'));
            if sign(CoordX(ris,1)) == -1
                Location = 'southeast';
            else
                Location = 'southwest';
            end
            if contaS_Mese > 1 && conta0_Mese > 1
                legend('Array geometry','Moving nodes','Stable nodes','Location',Location);
            elseif contaS_Mese > 1 && conta0_Mese == 1
                legend('Array geometry','Moving nodes','Location',Location);
            elseif contaS_Mese == 1 && conta0_Mese > 1
                legend('Array geometry','Stable nodes','Location',Location);
            end
            title('Local displacements - reference time priod');
            xlabel('X [m]');
            ylabel('Z [m]');
            h = gca;
            h.XAxis.MinorTick = 'on';
            h.YAxis.MinorTick = 'on';
            grid off
            TempName = char(strcat('Report',siteID,'-', char(toolrif),'SezRAD-Mese_ENG.png'));
            saveas(ancora,TempName);
            ChartSEZ_Mese = Image(TempName);
            ChartSEZ_Mese.Style = {HAlign('center'),Height('6.5cm')};
            
            % --- Geometria Strumento - Intero periodo ---
            % --- Sezione - TOT ---
            contaS_Tot = 1;
            conta0_Tot = 1;
            contaSX = 1;
            contaD = 1;
            contaT = 1;
            contaA = 1;
            contaB = 1;
            contaXZ = 1;
            contaG = 1;
            clear nodi0X
            clear nodi0Z
            clear nodiSX
            clear nodiSZ
            for ris = 1:nn % Ho aggiunto l'ancora
                if RIS_XYZ_Tot(end,ris)> 0.5
                    if cX_Tot(1,ris) > 70 %
                       if sigX_Tot(1,ris) == 1 % Destra
                           nodiD_X(contaD,1) = CoordX(ris,1);
                           nodiD_Z(contaD,1) = CoordZ(ris,1);
                           contaD = contaD+1;
                       else % sinistra
                           nodiS_X(contaSX,1) = CoordX(ris,1);
                           nodiS_Z(contaSX,1) = CoordZ(ris,1);
                           contaSX = contaSX+1;
                       end
                    elseif cY_Tot(1,ris) > 70 % Trasversale
                        nodiT_X(contaT,1) = CoordX(ris,1);
                        nodiT_Z(contaT,1) = CoordZ(ris,1);
                        contaT = contaT+1;
                    elseif cZ_Tot(1,ris) > 70
                        if sigZ_Tot(1,ris) == 1 % Verso l'alto
                            nodiA_X(contaA,1) = CoordX(ris,1);
                            nodiA_Z(contaA,1) = CoordZ(ris,1);
                            contaA = contaA+1;
                        else % Verso il basso
                            nodiB_X(contaB,1) = CoordX(ris,1);
                            nodiB_Z(contaB,1) = CoordZ(ris,1);
                            contaB = contaB+1;
                        end
                    elseif cX_Tot(1,ris)+cZ_Tot(1,ris) > 70 % 45 gradi circa
                            nodiXZ_X(contaXZ,1) = CoordX(ris,1);
                            nodiXZ_Z(contaXZ,1) = CoordZ(ris,1);
                            contaXZ = contaXZ+1;
                    else % Moto Generico
                        nodi_X(contaG,1) = CoordX(ris,1);
                        nodi_Z(contaG,1) = CoordZ(ris,1);
                        contaG = contaG+1;
                    end
                    nodiSX(contaS_Tot,1) = CoordX(ris,1);
                    nodiSZ(contaS_Tot,1) = CoordZ(ris,1);
                    contaS_Tot = contaS_Tot+1;
                else % Stabili
                    nodi0X(conta0_Tot,1) = CoordX(ris,1);
                    nodi0Z(conta0_Tot,1) = CoordZ(ris,1);
                    conta0_Tot = conta0_Tot+1;
                end
            end
            figure(3)
            plot([0;CoordX(:,1)],[0;CoordZ(:,1)],'-','Color','black');
            hold on
            % Spostamenti generici
            if contaG > 1
                sezG = plot(nodi_X(:,1),nodi_Z(:,1),'o','Color','red');
                set(sezG, 'markerfacecolor', get(sezG, 'color'));
            end
            % Spostamenti Alto
            if contaA > 1
                sezA = plot(nodiA_X(:,1),nodiA_Z(:,1),'^','Color',[0.4660 0.6740 0.1880],'MarkerSize' ,7);
                set(sezA, 'markerfacecolor', get(sezA, 'color'));
            end
            % Spostamenti Basso
            if contaB > 1
                sezB = plot(nodiB_X(:,1),nodiB_Z(:,1),'v','Color',[0.4660 0.6740 0.1880],'MarkerSize' ,7);
                set(sezB, 'markerfacecolor', get(sezB, 'color'));
            end
            % Spostamenti Destra
            if contaD > 1
                sezD = plot(nodiD_X(:,1),nodiD_Z(:,1),'>','Color','blue','MarkerSize' ,7);
                set(sezD, 'markerfacecolor', get(sezD, 'color'));
            end
            % Spostamenti Sinistra
            if contaSX > 1
                sezSX = plot(nodiS_X(:,1),nodiS_Z(:,1),'<','Color',[0.3010 0.7450 0.9330],'MarkerSize' ,7);
                set(sezSX, 'markerfacecolor', get(sezSX, 'color'));
            end
            % Spostamenti 45°
            if contaXZ > 1
                sezXZ = plot(nodiXZ_X(:,1),nodiXZ_Z(:,1),'x','Color',[0.8500 0.3250 0.0980],'MarkerSize' ,13);
                set(sezXZ, 'markerfacecolor', get(sezXZ, 'color'));
            end
            % Sensori Fermi
            if conta0_Tot > 1
                sez0 = plot(nodi0X(:,1),nodi0Z(:,1),'o','Color','black');
                set(sez0, 'markerfacecolor', get(sez0, 'color'));
            end
            ancora = plot(0,0,'s','Color','black','MarkerSize' ,13);
            set(ancora, 'markerfacecolor', get(ancora, 'color'));
            if sign(CoordX(ris,1)) == -1
                Location = 'southeast';
            else
                Location = 'southwest';
            end
            if contaG > 1 && contaA > 1 && contaB > 1 && contaD > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements','Downward displacements',...
                    'Right direction shift','Left direction shift','2D displacements','Stable nodes','Location',Location);
            elseif contaG > 1 && contaD > 1 && contaSX > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Right direction shift',...
                'Left direction shift','Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaB > 1 && contaD > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements','Downward displacements',...
                    'Right direction shift','Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaB > 1 && contaSX > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements','Downward displacements',...
                    'Left direction shift','Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaD > 1 && contaSX > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements',...
                    'Right direction shift','Left direction shift','Stable nodes','Location',Location);
            elseif contaG > 1 && contaB > 1 && contaD > 1 && contaSX > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Downward displacements',...
                    'Right direction shift','Left direction shift','Stable nodes','Location',Location);
            elseif contaG > 1 && contaB > 1 && contaD > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Downward displacements',...
                    'Right direction shift','Left direction shift','2D displacements',...
                    'Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaD > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements',...
                    'Right direction shift','Left direction shift','2D displacements',...
                    'Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaB > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements','Downward displacements',...
                    'Left direction shift','2D displacements','Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaB > 1 && contaD > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements','Downward displacements',...
                    'Right direction shift','2D displacements','Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaB > 1 && contaD > 1 && contaSX > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements','Downward displacements',...
                    'Right direction shift','Left direction shift','Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaB > 1 && contaD > 1 && contaSX > 1 && contaXZ > 1
                legend('Array geometry','3D displacements','Upward displacements','Downward displacements',...
                    'Right direction shift','Left direction shift','2D displacements','Location',Location);
            elseif contaG > 1 && contaD > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements',...
                    'Right direction shift','Left direction shift','2D displacements','Stable nodes',...
                    'Location',Location);  
            elseif contaG > 1 && contaB > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Downward displacements',...
                    'Left direction shift','2D displacements','Stable nodes','Location',Location);
            elseif contaG > 1 && contaB > 1 && contaD > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Downward displacements',...
                    'Right direction shift','2D displacements','Stable nodes','Location',Location);
            elseif contaG > 1 && contaB > 1 && contaD > 1 && contaSX > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Downward displacements',...
                    'Right direction shift','Left direction shift','Stable nodes','Location',Location);
            elseif contaG > 1 && contaB > 1 && contaD > 1 && contaSX > 1 && contaXZ > 1
                legend('Array geometry','3D displacements','Downward displacements',...
                    'Right direction shift','Left direction shift','2D displacements','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements',...
                    'Left direction shift','2D displacements','Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaD > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements',...
                    'Right direction shift','2D displacements','Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaD > 1 && contaSX > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements',...
                    'Right direction shift','Left direction shift','Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaD > 1 && contaSX > 1 && contaXZ > 1
                legend('Array geometry','3D displacements','Upward displacements',...
                    'Right direction shift','Left direction shift','2D displacements','Location',Location);
            elseif contaA > 1 && contaB > 1 && contaD > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','Upward displacements','Downward displacements',...
                    'Right direction shift','Left direction shift','2D displacements',...
                    'Stable nodes','Location',Location);
            elseif contaB > 1 && contaD > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','Downward displacements',...
                    'Right direction shift','Left direction shift','2D displacements',...
                    'Stable nodes','Location',Location);
            elseif contaA > 1 && contaD > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','Upward displacements',...
                    'Right direction shift','Left direction shift','2D displacements',...
                    'Stable nodes','Location',Location);
            elseif contaA > 1 && contaB > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','Upward displacements','Downward displacements',...
                    'Left direction shift','2D displacements','Stable nodes','Location',Location);
            elseif contaA > 1 && contaB > 1 && contaD > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','Upward displacements','Downward displacements',...
                    'Right direction shift','2D displacements','Stable nodes','Location',Location);
            elseif contaA > 1 && contaB > 1 && contaD > 1 && contaSX > 1 && conta0_Tot > 1
                legend('Array geometry','Upward displacements','Downward displacements',...
                    'Right direction shift','Left direction shift','Stable nodes','Location',Location);
            elseif contaA > 1 && contaB > 1 && contaD > 1 && contaSX > 1 && contaXZ > 1
                legend('Array geometry','Upward displacements','Downward displacements',...
                    'Right direction shift','Left direction shift','2D displacements','Location',Location);
            elseif contaB > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','Downward displacements','Left direction shift',...
                    '2D displacements','Stable nodes','Location',Location);
            elseif contaB > 1 && contaD > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','Downward displacements',...
                    'Right direction shift','2D displacements','Stable nodes','Location',Location);
            elseif contaB > 1 && contaD > 1 && contaSX > 1 && conta0_Tot > 1
                legend('Array geometry','Downward displacements',...
                    'Right direction shift','Left direction shift','Stable nodes','Location',Location);
            elseif contaB > 1 && contaD > 1 && contaSX > 1 && contaXZ > 1
                legend('Array geometry','Downward displacements',...
                    'Right direction shift','Left direction shift','2D displacements','Location',Location);
            elseif contaD > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','Right direction shift','Left direction shift',...
                    '2D displacements','Stable nodes','Location',Location);
            elseif contaG > 1 && contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Left direction shift',...
                    '2D displacements','Stable nodes','Location',Location);
            elseif contaG > 1 && contaD > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Right direction shift',...
                    '2D displacements','Stable nodes','Location',Location);
            elseif contaG > 1 && contaB > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Downward displacements','Stable nodes','Location',Location);
            elseif contaG > 1 && contaD > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Right direction shift','Stable nodes','Location',Location);
            elseif contaG > 1 && contaSX > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Left direction shift','Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && contaB > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements','Downward displacements',...
                    'Stable nodes','Location',Location);
            elseif contaG > 1 && contaA > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Upward displacements','Stable nodes','Location',Location);
            elseif contaG > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','2D displacements',...
                    'Stable nodes','Location',Location);
            elseif contaG > 1 && contaXZ > 1
                legend('Array geometry','3D displacements','2D displacements','Location',Location);
            elseif contaG > 1 && conta0_Tot > 1
                legend('Array geometry','3D displacements','Stable nodes','Location',Location);
            elseif contaD > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','Right direction shift',...
                    '2D displacements','Stable nodes','Location',Location);
            elseif contaD > 1 && contaSX > 1 && conta0_Tot > 1
                legend('Array geometry','Right direction shift','Left direction shift',...
                    'Stable nodes','Location',Location);
            elseif contaD > 1 && contaSX > 1 && contaXZ > 1
                legend('Array geometry','Right direction shift','Left direction shift',...
                    '2D displacements','Location',Location);
            elseif contaSX > 1 && contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','Left direction shift',...
                    '2D displacements','Stable nodes','Location',Location);
            elseif contaSX > 1 && conta0_Tot > 1
                legend('Array geometry','Left direction shift',...
                    'Stable nodes','Location',Location);
            elseif contaSX > 1 && contaXZ > 1
                legend('Array geometry','Left direction shift',...
                    '2D displacements','Location',Location);
            elseif contaXZ > 1 && conta0_Tot > 1
                legend('Array geometry','2D displacements','Stable nodes','Location',Location);
            elseif conta0_Tot > 1
                legend('Array geometry','Stable nodes','Location',Location);
            elseif contaG > 1 
                legend('Array geometry','3D displacements','Location',Location);
            elseif contaA > 1
                legend('Array geometry','Upward displacements','Location',Location);
            elseif contaB > 1 
                legend('Downward displacements','Location',Location);
            elseif contaD > 1
                legend('Array geometry','Right direction shift','Location',Location);
            elseif contaSX > 1
                legend('Array geometry','Left direction shift','Location',Location);
            elseif contaXZ > 1
                legend('Array geometry','2D displacements','Location',Location);
            end
            
            title('Local displacemets - complete monitoring period');
            xlabel('X [m]');
            ylabel('Z [m]');
            h = gca;
            h.XAxis.MinorTick = 'on';
            h.YAxis.MinorTick = 'on';
            grid off
            TempName = char(strcat('Report',siteID,'-', char(toolrif),'SezRAD-Tot_ENG.png'));
            saveas(ancora,TempName);            
            ChartSEZ = Image(TempName);
            ChartSEZ.Style = {HAlign('center'),Height('6.5cm')};
			ChartSEZ_cap = Paragraph(['Fig. ' num2str(FIG) ' - Graphical illsutration '...
						'of each single node behaviour, based on the 3D local differential displacement vector, recorded '...
						'during the reference time period and the complete monitoring period']);

            FIG = FIG+1;
            ChartSEZ_cap.Style = {HAlign('justify'),FontSize(Font_caption),Italic(1),Color('midnightblue')};        
            
            lot = Table({ChartSEZ_Mese, ChartSEZ});
            lot.Style = {ResizeToFitContents(false), Width('100%')};
            
            sezRAD = Heading3('Radial Link');
            sezRAD.Style = {FontSize(Font_tools),Bold(1),Italic(1)};
            RA = Section();
            RA.Title = sezRAD;
            % Testi relativi all'ultimo mese
			            testo1 = Paragraph(['The following graph presents the 3D local differential displacement vectors '...
					'recorded by Radial Links during the reference time period and the complete monitoring period. '...
					'The 3D vector is computed as a resultant of X-Y-Z component vectors, corresponding to width, depth and height '...
					'of the monitored section, respectively.']);
            testo2 = Paragraph(['The corresponding figure summarizes the behaviour of the Array, '...
				'by representing each single node on the original configuration of the tool. During the '...
                'reference time period, the analysis highlighted ' ...
                num2str(contaS_Mese-1) ' nodes featuring displacements and ' num2str(conta0_Mese-1) ' stable nodes. '...
                'In this specific representation, nodes characterized by displacement values less than 0.5 mm '...
				'are assumed as stable']);

            spazio = Paragraph('');
            testo1.HAlign = 'justify';
            testo2.HAlign = 'justify';
            
            add(DT,sezRAD);
            add(DT,testo1);
            add(DT,ChartRad);
            add(DT,ChartRad_cap);
            add(DT,testo2);
            add(DT,spazio);
            add(DT,lot);
            add(DT,ChartSEZ_cap);
            add(DT,br);
            
            close(figure(1));
            close(figure(2));
            close(figure(3));
        else
            if ATTIVA == 1
            testo = Paragraph('No data available for the reference time period.');
                ATTIVA = 0;
                add(DT,testo);
                check = 1;
            end
        end
    end
end
    
fileID = fopen(FileName,'a');
fmt = '%s \r';
text = 'report_RaL_ENG function executed correctly';
fprintf(fileID,fmt,text);
fclose(fileID);
    
end