function [Y_PCL,Z_PCL,Ylocal_PCL,Zlocal_PCL,AlfaX_PCL,AlfaY_PCL,TempDef_PCL,... speed_PCL,speed_local_PCL,acceleration_PCL,acceleration_local_PCL,ARRAYdate_PCL,... ErrPreConvLink] = elab2D_PCL(IDcentralina,DTcatena,rPCL,accPCL,ACCdefRis_PCL,... TempDef_PCL,SpePCL,tolleranzaAcc,DatiElabPreConvLink,Ndevst,Wdevst,ARRAYdate_PCL,... NuovoZeroPCL,NdatiMedia,Ndatidespike,ErrPreConvLink,margine,elab_option,... Tmax,Tmin,datainiPCL,FileName) %% Inizializzazione fileID = fopen(FileName,'a'); fmt = '%s \r'; text = 'elab2D_PCL function started'; fprintf(fileID,fmt,text); if NuovoZeroPCL == 1 if NdatiMedia > Ndatidespike Ndati = NdatiMedia; else Ndati = Ndatidespike; end ini = round(Ndati/2)+1; if rem(Ndati,2) == 0 ini = ini+1; end clear NDati ini = ini + margine; if ini < 6 ini = 6; end if Ndevst ~= 0 % Allora prendo tutti i dati e solo in seguito considero i nuovi, a valle della funzione filtro ini = 1; end accPCL = accPCL(ini:end,:); ACCdefRis_PCL = ACCdefRis_PCL(ini:end,:); TempDef_PCL = TempDef_PCL(ini:end,:); DatiElabPreConvLink = DatiElabPreConvLink(ini:end,:); ARRAYdate_PCL = ARRAYdate_PCL(ini:end,1); ErrPreConvLink = ErrPreConvLink(ini:end,:); end %% Definisco i dati Nnodi = rPCL; % Spacchetto [r,~] = size(accPCL); % Numero di dati [Ndati,~] = size(ARRAYdate_PCL); ax = zeros(r,Nnodi); ay = zeros(r,Nnodi); for i=1:Nnodi ax(:,i) = accPCL(:,(i-1)*3+1); % ax ay(:,i) = accPCL(:,(i-1)*3+2); % ay end ax = ax'; % riga nodi, colonna date ay = ay'; % riga nodi, colonna date %% Costruzione delle matrici % Dati locali asseY_PCL = zeros(Nnodi,Ndati); % Raccoglie i dati planari locali nella direzione di sviluppo della catena asseZ_PCL = zeros(Nnodi,Ndati); % Raccoglie i dati planari locali nella direzione di sviluppo della catena, basso->alto % Dati cumulati Y_PCL = zeros(Nnodi,Ndati); % Raccoglie i dati cumulati nella direzione di sviluppo della catena Z_PCL = zeros(Nnodi,Ndati); % Raccoglie i dati cumulati nella direzione di sviluppo della catena, basso->alto AlfaX_PCL = zeros(Nnodi,Ndati); AlfaY_PCL = zeros(Nnodi,Ndati); % % parametri per il calcolo SpePCL = SpePCL(2:end,1); % valori segmenti di pertinenza % Inizio del ciclo di elaborazione text = 'Elaboration of PreConv Link started'; fprintf(fileID,fmt,text); for jj = 1:Ndati if jj == 1 % al primo dato raccolto riporto i punti di calcolo sui punti noti % INPUT SITO SPECIFICO DA DARE !!! fclose(fileID); if NuovoZeroPCL == 0 [cYo,cZo,~,~] = punti_noti_PCL(elab_option,... IDcentralina,DTcatena,FileName); elseif NuovoZeroPCL == 1 % calcolo a partire da dati già elaborati a cui mi riferisco [cYo,cZo,~,~] = punti_noti_exe_PCL(asseY_PCL,... DatiElabPreConvLink,elab_option,FileName); end for ii = 1:Nnodi [Y_PCL,Z_PCL,asseY_PCL,asseZ_PCL,AlfaX_PCL,AlfaY_PCL] = CalcoloBiax_PCL(SpePCL,... ii,jj,ax,ay,asseY_PCL,asseZ_PCL,Y_PCL,Z_PCL,... AlfaX_PCL,AlfaY_PCL,elab_option,rPCL,IDcentralina,DTcatena); end [shiftY_PCL,shiftZ_PCL] = pos_ini_PCL(cYo,cZo,Y_PCL,Z_PCL); else for ii = 1:Nnodi [Y_PCL,Z_PCL,asseY_PCL,asseZ_PCL,AlfaX_PCL,AlfaY_PCL] = CalcoloBiax_PCL(SpePCL,... ii,jj,ax,ay,asseY_PCL,asseZ_PCL,Y_PCL,Z_PCL,... AlfaX_PCL,AlfaY_PCL,elab_option,rPCL,IDcentralina,DTcatena); end end % riporto Y e Z sui punti noti Y_PCL(:,jj) = Y_PCL(:,jj) - shiftY_PCL(:,1); Z_PCL(:,jj) = Z_PCL(:,jj) - shiftZ_PCL(:,1); end Yrif = Y_PCL; % mi serve dopo Zrif = Z_PCL; % mi serve dopo dY_PCL = diff(asseY_PCL,1,2); dZ_PCL = diff(asseZ_PCL,1,2); %% Controllo della risultante delle accelerazioni clear r clear rr clear c clear cc ACCdefRis_PCL = ACCdefRis_PCL'; % Nodi in riga, date in colonna [r,c] = size(ACCdefRis_PCL); [rr,cc] = size(Y_PCL); % controllo che le matrici con le risultanti delle accelerazioni e % le matrici con i dati di spostamento abbiano le stesse dimensioni if r~=rr || c~=cc text = 'Warning! Displacement data and g vector have not the same size!'; else text = 'There are not warning for PreConv Link'; end fileID = fopen(FileName,'a'); fmt = '%s \r'; fprintf(fileID,fmt,text); clear i clear j cont = 1; % contatore cont2 = 1; % contatore cont3 = 1; % contatore TempDef_PCL = TempDef_PCL'; text1 = 'There are not correction of PreConv Link based on acceleration vector filter'; text2 = 'There are not correction of PreConv Link based on uncalibrated Acceleration vector'; text3 = 'There are not correction of PreConv Link based on temperature filter'; for j = 2:c % data for i = 1:r % nodo % se il valore assoluto della differenza è maggiore della % tolleranza, pongo gli spostamenti giornalieri pari a 0 if abs(ACCdefRis_PCL(i,j)-ACCdefRis_PCL(i,j-1)) > tolleranzaAcc dY_PCL(i,j-1) = 0; dZ_PCL(i,j-1) = 0; text1 = ['' num2str(cont) ' correction executed for PreConv Link - Acceleration vector filter!']; cont = cont+1; end if ACCdefRis_PCL(i,j) < 0.9 || ACCdefRis_PCL(i,j) > 1.1 % Il nodo è fuori taratura! dY_PCL(i,j-1) = 0; dZ_PCL(i,j-1) = 0; TempDef_PCL(i,j) = TempDef_PCL(i,j-1); text2 = ['' num2str(cont3) ' correction executed for PreConv Link - uncalibrated Acceleration vector!']; cont3 = cont3+1; end end end FileTemperature = ['' IDcentralina '-' DTcatena '-PCL-Therm.csv']; if isfile(FileTemperature) == 1 DatiRaw = csvread(FileTemperature); [rDR,cDR] = size(DatiRaw); DatiRaw(:,1) = DatiRaw(:,1) + 730000; else rDR = 1; cDR = 1; end for b = 1:c % Data for a = 1:r % Nodo % NON considero i dati al di sopra dei 80 °C o al di sotto dei -30 °C! if TempDef_PCL(a,b) > Tmax || TempDef_PCL(a,b) < Tmin cont2 = cont2+1; if b == 1 if isfile(FileTemperature) == 1 RawDate = find(DatiRaw(:,1)<=datenum(datainiPCL)); if isempty(RawDate) == 1 cc = 2; while cc <= c if TempDef_PCL(a,cc) > Tmax || TempDef_PCL(a,cc) < Tmin cc = cc+1; else break end end TempDef_PCL(a,b) = TempDef_PCL(a,cc); else if isnan(DatiRaw(RawDate(end),a+1)) == 0 TempDef_PCL(a,b) = DatiRaw(RawDate(end),a+1); ErrPreConvLink(b,a) = 0.5; wardat = 'Temperature data of PreConv Link nodes corrected using Raw Data of reference Csv file.'; fprintf(fileID,fmt,wardat); else cc = 2; while cc <= c if TempDef_PCL(a,cc) > Tmax || TempDef_PCL(a,cc) < Tmin cc = cc+1; else break end end TempDef_PCL(a,b) = TempDef_PCL(a,cc); end end else cc = 2; while cc <= c if TempDef_PCL(a,cc) > Tmax || TempDef_PCL(a,cc) < Tmin cc = cc+1; else break end end TempDef_PCL(a,b) = TempDef_PCL(a,cc); end else TempDef_PCL(a,b) = TempDef_PCL(a,b-1); dY_PCL(a,b-1) = 0; dZ_PCL(a,b-1) = 0; ErrPreConvLink(b,a) = 0.5; end text3 = ['' num2str(cont2) ' correction executed for PreConv Link - Temperature filter!']; end end end if rDR~=1 && cDR~=1 && isempty(DatiRaw) == 0 RawDate1 = find(DatiRaw(:,1)<=ARRAYdate_PCL(1)); if isempty(RawDate1) == 1 RawDate2 = 1; elseif RawDate1(end) == rDR RawDate2 = find(ARRAYdate_PCL(:,1)>DatiRaw(end,1)); else RawDate2 = find(ARRAYdate_PCL(:,1)>DatiRaw(RawDate1(end)+1,1)); end else RawDate1 = []; RawDate2 = 1; end if isempty(RawDate1) == 0 && isempty(RawDate2) == 0 Dati = [DatiRaw(1:RawDate1(end),:); ARRAYdate_PCL(RawDate2(1):end) TempDef_PCL(:,RawDate2(1):end)']; elseif isempty(RawDate1) == 1 && isempty(RawDate2) == 0 Dati = [ARRAYdate_PCL TempDef_PCL']; else Dati = DatiRaw; end % Elimino appoggio più vecchio di un mese RawDate3 = find(Dati(:,1) Ndatidespike NdatiF = NdatiMedia; else NdatiF = Ndatidespike; end ini = round(NdatiF/2)+1; if rem(NdatiF,2) == 0 ini = ini+1; end clear NDatiF iniST = round(Wdevst/2); if rem(Wdevst,2) == 0 iniST = iniST+1; end iniST = iniST + margine; if iniST > ini ini = iniST; end if ini < 6 ini = 6; end dY_PCL = dY_PCL(:,ini:end); dZ_PCL = dZ_PCL(:,ini:end); TempDef_PCL = TempDef_PCL(ini:end,:); DatiElabPreConvLink = DatiElabPreConvLink(ini:end,:); ARRAYdate_PCL = ARRAYdate_PCL(ini:end,1); ErrPreConvLink = ErrPreConvLink(ini:end,:); end %% Finalizzo i calcoli [rx,cx] = size(dZ_PCL); % totale del singolo nodo data per data sommaY_PCL = zeros(rx,cx+1); sommaZ_PCL = zeros(rx,cx+1); % cumulata del singolo nodo data per data in posizione assoluta % il primo valore è quello di posizione assoluta iniziale Y_PCL = zeros(rx,cx+1); Z_PCL = zeros(rx,cx+1); % cumulata del singolo nodo data per data in posizione relativa % il primo valore è quello di posizione assoluta iniziale Ylocal_PCL = zeros(Nnodi,Ndati); Zlocal_PCL = zeros(Nnodi,Ndati); speed_PCL = zeros(Nnodi,Ndati); speed_local_PCL = zeros(Nnodi,Ndati); acceleration_PCL = zeros(Nnodi,Ndati); acceleration_local_PCL = zeros(Nnodi,Ndati); if NuovoZeroPCL == 1 [rE,cE] = size(DatiElabPreConvLink); cont = 3; contINV = 10; n = 1; while cont<=cE if elab_option == 1 sommaY_PCL(n,1) = cell2mat(DatiElabPreConvLink(1,cont))'; Ylocal_PCL(n,1) = sommaY_PCL(n,1); sommaZ_PCL(n,1) = cell2mat(DatiElabPreConvLink(1,cont+1))'; Zlocal_PCL(n,1) = sommaZ_PCL(n,1); Y_PCL(n,1) = cell2mat(DatiElabPreConvLink(1,cont+2))'; Z_PCL(n,1) = cell2mat(DatiElabPreConvLink(1,cont+3))'; speed_local_PCL(n,1:rE) = cell2mat(DatiElabPreConvLink(:,cont+7))'; speed_PCL(n,1:rE) = cell2mat(DatiElabPreConvLink(:,cont+8))'; acceleration_local_PCL(n,1:rE) = cell2mat(DatiElabPreConvLink(:,cont+9))'; acceleration_PCL(n,1:rE) = cell2mat(DatiElabPreConvLink(:,cont+10))'; elseif elab_option == -1 sommaY_PCL(end-n+1,1) = cell2mat(DatiElabPreConvLink(1,cE-contINV))'; Ylocal_PCL(end-n+1,1) = sommaY_PCL(end-n+1,1); sommaZ_PCL(end-n+1,1) = cell2mat(DatiElabPreConvLink(1,cE-contINV+1))'; Zlocal_PCL(end-n+1,1) = sommaZ_PCL(end-n+1,1); Y_PCL(end-n+1,1) = cell2mat(DatiElabPreConvLink(1,cE-contINV+2))'; Z_PCL(end-n+1,1) = cell2mat(DatiElabPreConvLink(1,cE-contINV+3))'; speed_local_PCL(end-n+1,1:rE) = cell2mat(DatiElabPreConvLink(:,cE-contINV+7))'; speed_PCL(end-n+1,1:rE) = cell2mat(DatiElabPreConvLink(:,cE-contINV+8))'; acceleration_local_PCL(end-n+1,1:rE) = cell2mat(DatiElabPreConvLink(:,cE-contINV+9))'; acceleration_PCL(end-n+1,1:rE) = cell2mat(DatiElabPreConvLink(:,cE-contINV+10))'; contINV = contINV+13; end cont = cont+13; n = n+1; end else % Primo dato Y_PCL(:,1) = Yrif(:,1); Z_PCL(:,1) = Zrif(:,1); end for iii = 1:cx % date % somma singoli spostamenti del singolo nodo sommaY_PCL(:,iii+1) = sum(dY_PCL(:,1:iii),2)+sommaY_PCL(:,1); sommaZ_PCL(:,iii+1) = sum(dZ_PCL(:,1:iii),2)+sommaZ_PCL(:,1); % spostamenti locali riferiti allo 0 Ylocal_PCL(:,iii+1) = sommaY_PCL(:,iii+1); Zlocal_PCL(:,iii+1) = sommaZ_PCL(:,iii+1); % cumulata spostamenti if elab_option == 1 Y_PCL(:,iii+1) = Y_PCL(:,1) + cumsum(sommaY_PCL(:,iii+1)) - cumsum(sommaY_PCL(:,1)); Z_PCL(:,iii+1) = Z_PCL(:,1) + cumsum(sommaZ_PCL(:,iii+1)) - cumsum(sommaZ_PCL(:,1)); elseif elab_option == -1 Y_PCL = flipud(Y_PCL); Z_PCL = flipud(Z_PCL); Y_PCL(:,iii+1) = Y_PCL(:,1) + cumsum(flipud(sommaY_PCL(:,iii+1))) - cumsum(flipud(sommaY_PCL(:,1))); Z_PCL(:,iii+1) = Z_PCL(:,1) + cumsum(flipud(sommaZ_PCL(:,iii+1))) - cumsum(flipud(sommaZ_PCL(:,1))); Y_PCL = flipud(Y_PCL); Z_PCL = flipud(Z_PCL); end end % %% Filtri Spostamenti - Temperature % Parametro1 = 288; % Numero di dati da considerare nell'analisi % Parametro2 = Parametro1*2; % Parametro3 = 0.04; % Parametro di filtro % % % Trovo ogni quanto leggiamo i sensori % comando = ['select samplingfreq from unitparms where unit_id like ''' unitID ''' ']; % curs = exec(conn,comando); % curs = fetch(curs); % Campionamento = curs.Data; % minuti % % Campionamento = cell2mat(Campionamento)/(60*24); % giorni % Data_Scarico = ARRAYdate_PCL(1)-(Parametro2*Campionamento); % dataini = datenum([date,' ',time]); % if Data_Scarico < dataini % Data_Scarico = dataini; % end % Data_Scarico = datestr(Data_Scarico,'yyyy-mm-dd HH:MM:SS'); % % col = 5; % for p = 1:rPCL % ini_col = col-4; % nN = num2str(cell2mat(NodoPreConvLink(p,2))); % scarico i dati del primo nodo PreConvLink % % Giorno 1 % comando = ['select EventDate, EventTime, YShift, ZShift, T_node from ElabDataView where EventDate = ''' ... % Data_Scarico(1,1:10) ''' and EventTime >= ''' Data_Scarico(1,12:end) ''' and UnitName = ''' IDcentralina... % ''' and ToolNameID = ''' DTcatena ''' and NodeNum = ''' nN ''' ']; % curs = exec(conn,comando); % curs = fetch(curs); % DATnodoPCLd = curs.Data; % % Giorno successivi % comando = ['select EventDate, EventTime, YShift, ZShift, T_node from ElabDataView where EventDate > ''' ... % Data_Scarico(1,1:10) ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''... % DTcatena ''' and NodeNum = ''' nN ''' ']; % curs = exec(conn,comando); % curs = fetch(curs); % DATnodoPCL = curs.Data; % [~,c1] = size(DATnodoPCL); % [~,c2] = size(DATnodoPCLd); % if c1 == c2 % DATnodoPCL = [DATnodoPCLd; DATnodoPCL]; % elseif c1 < c2 % solo giorno di riferimento % DATnodoPCL = DATnodoPCLd; % end % DatiScaricoPCL(:,ini_col:col) = DATnodoPCL(:,:); % Z(:,p) = cell2mat(DatiScaricoPCL(:,ini_col+3)); % T(:,p) = cell2mat(DatiScaricoPCL(:,ini_col+4)); % Data(:,p) = DatiScaricoPCL(:,ini_col); % Tempo(:,p) = DatiScaricoPCL(:,ini_col+1); % col = col+5; % end % [rD,~] = size(Data); % Td = [cell2mat(Data(:,1)) repmat(' ', [rD,1]) cell2mat(Tempo(:,2))]; % Td = datenum(Td); % DateElab = Td; % DatiNew = find(ARRAYdate_PCL(:,1)>DateElab(end,1)); % [rDN,~] = size(DatiNew); % NN = rD+rDN; % % if rDN == 0 % Zlocal = Z; % Temp = T; % Date = DateElab; % else % Zlocal = [Z; Zlocal_PCL(:,DatiNew(1))']; % Temp = [T; TempDef_PCL(DatiNew(1),:)]; % Date = [DateElab; ARRAYdate_PCL(DatiNew(1),:)]; % end % [dimZ,~] = size(Zlocal); % if dimZ < Parametro2 % Parametro2 = dimZ; % Parametro1 = round(Parametro2/2); % end % % Parametri iniziali % MaxZ = zeros(Parametro2,rPCL); % MaxT = zeros(Parametro2,rPCL); % MinZ = zeros(Parametro2,rPCL); % MinT = zeros(Parametro2,rPCL); % MedZ = zeros(Parametro2,rPCL); % MedT = zeros(Parametro2,rPCL); % DiffZ = zeros(Parametro2,rPCL); % DiffT = zeros(Parametro2,rPCL); % Znorm = zeros(Parametro2,rPCL); % Tnorm = zeros(Parametro2,rPCL); % for i = 1:rPCL % off = 0; % for a = Parametro1:NN % MaxZ(a,i) = max(Zlocal(a-Parametro1+1:Parametro1+off,i)); % MinZ(a,i) = min(Zlocal(a-Parametro1+1:Parametro1+off,i)); % MedZ(a,i) = mean(Zlocal(a-Parametro1+1:Parametro1+off,i)); % MaxT(a,i) = max(Temp(a-Parametro1+1:Parametro1+off,i)); % MinT(a,i) = min(Temp(a-Parametro1+1:Parametro1+off,i)); % MedT(a,i) = mean(Temp(a-Parametro1+1:Parametro1+off,i)); % DiffZ(a,i) = MaxZ(a,i)-MinZ(a,i); % if DiffZ(a,i) == 0 % DiffZ(a,i) = 0.000001; % end % DiffT(a,i) = MaxT(a,i)-MinT(a,i); % if DiffT(a,i) == 0 % DiffT(a,i) = 0.000001; % end % Znorm(a,i) = (Zlocal(a,i)-MedZ(a,i))/DiffZ(a,i); % Tnorm(a,i) = (Temp(a,i)-MedT(a,i))/DiffT(a,i); % off = off+1; % end % end % % Parametri secondari % Pendenza_Z = zeros(NN-Parametro2+1,rPCL); % Intercetta_Z = zeros(NN-Parametro2+1,rPCL); % Pendenza_T = zeros(NN-Parametro2+1,rPCL); % Intercetta_T = zeros(NN-Parametro2+1,rPCL); % diffM = zeros(NN-Parametro2+1,rPCL); % for i = 1:rPCL % off = 0; % for a = Parametro2:NN % p = fitlm(Date(Parametro1+off:a,1),Znorm(Parametro1+off:a,i),'RobustOpts','on'); % p = p.Coefficients; % Parameter(1,1) = table2array(p(1,1)); % Parameter(2,1) = table2array(p(2,1)); % Pendenza_Z(a,i) = Parameter(2,1); % Intercetta_Z(a,i)= Parameter(1,1); % p = fitlm(Date(Parametro1+off:a,1),Tnorm(Parametro1+off:a,i),'RobustOpts','on'); % p = p.Coefficients; % Parameter(1,1) = table2array(p(1,1)); % Parameter(2,1) = table2array(p(2,1)); % Pendenza_T(a,i) = Parameter(2,1); % Intercetta_T(a,i)= Parameter(1,1); % diffM(a,i) = abs(Pendenza_Z(a,i))-abs(Pendenza_T(a,i)); % off = off+1; % end % end % % tic % % % valori di primo tentativo parametro % aT = zeros(1,rPCL); % bT = zeros(1,rPCL); % % options = optimset('MaxIter',100000,'TolFun',1e-6); % for i = 1:rPCL % off = 0; % for j = Parametro2:NN % e = 1; % iter = 1; % while e >= 0.00001 && iter < 3000 % % Ciclo intercetta % x0 = [aT(i) bT(i)]; % TempMod(j,i) = x0(1)*Temp(j,i)+x0(2); % scarti = @(x)calibPCL(x,Temp,i,j,Parametro1,off,Zlocal,TempMod); % x = fminsearch(scarti,x0); % e = max(abs(x-x0)); % x0 = x; % iter = iter+1; % end % Zfil(j,i) = (Zlocal(j,i)-TempMod(j,i)); % Come valuto l'incremento?! % off = off+1; % end % end % for i = 1:rPCL % for j = Parametro2:NN % % Da qualche parte devo risommare gli incrementi % if diffM(j,i) < Parametro3 % Zlocal_PCL(j,i) = Zfil(j,i)-Zfil(j-1,i)+Z_Loc(Parametro2-1,i); % incremento % else % Zlocal_PCL(j,i) = Zlocal(j,i)-Zlocal(j-1,i)+Z_Loc(Parametro2-1,i); % incremento % end % end % end % % toc %% Calcolo velocità di spostamento giornaliera [numDate,~] = size(ARRAYdate_PCL); % numero di date d = 1; p = 1; diffDate = 0; n = 1; period = 1; % calcolo giornaliero ContSUP = []; for dd = 1:numDate while diffDate < period d = d+1; if d > numDate % Se d supera le date disponibili, esco dal ciclo while break end diffDate = ARRAYdate_PCL(d) - ARRAYdate_PCL(p); end if d >numDate break end ContSUP(n,1) = d; %#ok<*AGROW> % Creo matrice indici dell'estremo superiore della differenza ContINF(n,1) = p; % Creo matrice indici dell'estremo inferiore della differenza p = p+1; % passo alla data di partenza successiva d = p; % resetto il conto di d n = n+1; diffDate = 0; end check = isempty(ContSUP); if check == 0 [nDate,~] = size(ContSUP); for s = 1:rPCL N = 1; for dd = 1:nDate speed_PCL(s,ContSUP(N,1)) = (Z_PCL(s,ContSUP(N,1))-Z_PCL(s,ContINF(N,1)))/(ARRAYdate_PCL(ContSUP(N,1))-ARRAYdate_PCL(ContINF(N,1))); speed_local_PCL(s,ContSUP(N,1)) = (Zlocal_PCL(s,ContSUP(N,1))-Zlocal_PCL(s,ContINF(N,1)))/(ARRAYdate_PCL(ContSUP(N,1))-ARRAYdate_PCL(ContINF(N,1))); acceleration_PCL(s,ContSUP(N,1)) = (speed_PCL(s,ContSUP(N,1))-speed_PCL(s,ContINF(N,1)))/(ARRAYdate_PCL(ContSUP(N,1))-ARRAYdate_PCL(ContINF(N,1))); acceleration_local_PCL(s,ContSUP(N,1)) = (speed_local_PCL(s,ContSUP(N,1))-speed_local_PCL(s,ContINF(N,1)))/(ARRAYdate_PCL(ContSUP(N,1))-ARRAYdate_PCL(ContINF(N,1))); N = N+1; end end end fclose(fileID); % Approssimo i dati con il corretto numero di cifre decimali [Y_PCL,Z_PCL,Ylocal_PCL,Zlocal_PCL,TempDef_PCL,speed_PCL,... speed_local_PCL,acceleration_PCL,acceleration_local_PCL,AlfaX_PCL,AlfaY_PCL] = ... approx_PCL(Y_PCL,Z_PCL,Ylocal_PCL,Zlocal_PCL,TempDef_PCL,speed_PCL,speed_local_PCL,... acceleration_PCL,acceleration_local_PCL,AlfaX_PCL,AlfaY_PCL,FileName); % Riordino matrice errori [r,~] = size(ErrPreConvLink); Matrice_err = zeros(r,rPCL); for i = 1:r % date d = 1; for n = 1:rPCL % nodi j = 1; err = ErrPreConvLink(i,d:d+3); while j <= 4 if err(1,j) == 1 Matrice_err(i,n) = 1; end j = j+1; end d = d+4; end end ErrPreConvLink = Matrice_err'; text = 'PreConv Link calculation executed correctly'; fileID = fopen(FileName,'a'); fmt = '%s \r'; fprintf(fileID,fmt,text); fclose(fileID); end