90 lines
2.5 KiB
Matlab
Executable File
90 lines
2.5 KiB
Matlab
Executable File
% Funzione che calcola il livello della falda
|
|
|
|
function [Livello,PiezDef,PiezDefT,ErrPiezoLink,ARRAYdatePL] = Piezo(PiezDef,PiezDefT,...
|
|
BaroDef,ARRAYdatePL,NuovoZeroPL,NdatiMediaP,Ndatidespike,NodoPiezoLink,ErrPiezoLink,rPL,...
|
|
Anchor_real,marginePiezo,FileName)
|
|
|
|
text = 'Piezo function started';
|
|
fileID = fopen(FileName,'a');
|
|
fmt = '%s \r';
|
|
fprintf(fileID,fmt,text);
|
|
|
|
if NuovoZeroPL == 1
|
|
if NdatiMediaP > Ndatidespike
|
|
Ndati = NdatiMediaP;
|
|
else
|
|
Ndati = Ndatidespike;
|
|
end
|
|
ini = round(Ndati/2)+1;
|
|
if rem(Ndati,2) == 0
|
|
ini = ini+1;
|
|
end
|
|
clear NDati
|
|
ini = ini + marginePiezo;
|
|
ErrPiezoLink = ErrPiezoLink(ini:end,:);
|
|
PiezDef = PiezDef(ini:end,:);
|
|
PiezDefT = PiezDefT(ini:end,:);
|
|
BaroDef = BaroDef(ini:end,:);
|
|
ARRAYdatePL = ARRAYdatePL(ini:end,1);
|
|
end
|
|
|
|
[dati,~] = size(PiezDef);
|
|
ProfFalda = zeros(dati,rPL); % in riga le date, in colonna i piezometri
|
|
for p = 1:rPL
|
|
if strcmp(NodoPiezoLink(1,4),'VW kPa') == 1 || strcmp(NodoPiezoLink(1,4),'VW kg/cm2') == 1
|
|
ProfFalda(:,p) = (PiezDef(:,p))/9806.65;
|
|
else
|
|
ProfFalda(:,p) = (PiezDef(:,p) - BaroDef(:,1))/9806.65;
|
|
end
|
|
end
|
|
|
|
if Anchor_real ~= 0 % correggo la profondità del piezometro
|
|
% Nodi = [cell2mat(catena(:,3)) cell2mat(catena(:,2)) cell2mat(catena(:,1))];
|
|
% [r,~] = size(Nodi);
|
|
% % Cerco l'ancora
|
|
% for i = 1:r
|
|
% if Nodi(i,3) == 9
|
|
% break
|
|
% end
|
|
% end
|
|
% diff = Anchor_real - Nodi(i,2);
|
|
NodoPiezoLink(:,3) = num2cell(cell2mat(NodoPiezoLink(:,3)) - Anchor_real);
|
|
end
|
|
|
|
Livello = zeros(dati,rPL); % Dove sta la falda rispetto al Piano Campagna
|
|
clear p
|
|
for ii = 1:dati
|
|
for p = 1:rPL
|
|
if ProfFalda(ii,p) <= 0 % La falda è sotto al piezometro e questo non può leggerne dunque la profondità
|
|
Livello(ii,p) = cell2mat(NodoPiezoLink(p,3));
|
|
else
|
|
Livello(ii,p) = cell2mat(NodoPiezoLink(p,3)) + ProfFalda(ii,p);
|
|
end
|
|
end
|
|
end
|
|
|
|
% Impacchettamento matrice errori
|
|
[r,~] = size(ErrPiezoLink);
|
|
Matrice_err = zeros(r,rPL);
|
|
for i = 1:r % date
|
|
d = 1;
|
|
for n = 1:rPL % nodi
|
|
j = 1;
|
|
err = ErrPiezoLink(i,d:d+1);
|
|
while j <= 2
|
|
if err(1,j) == 1
|
|
Matrice_err(i,n) = 1;
|
|
break
|
|
end
|
|
j = j+1;
|
|
end
|
|
d = d+2;
|
|
end
|
|
end
|
|
ErrPiezoLink = Matrice_err';
|
|
|
|
text = 'Piezo Link elaborated correctly. Piezo function closed';
|
|
fprintf(fileID,fmt,text);
|
|
fclose(fileID);
|
|
|
|
end |