% Funzione che approssima il dato alla quarta cifra decimale (decimi di
% millimetri)
function [X,Y,Z,Xlocal,Ylocal,Zlocal,HShift,HShift_local,Azimuth,Speed,...
    Speed_local,Acceleration,Acceleration_local,TempDef_TL] = approx(X,Y,Z,...
    Xlocal,Ylocal,Zlocal,HShift,HShift_local,Azimuth,Speed,Speed_local,...
    Acceleration,Acceleration_local,TempDef_TL,FileName)
        
text = 'approx function started';
fileID = fopen(FileName,'a');
fmt = '%s \r';
fprintf(fileID,fmt,text);

conv = X*10000;
conv = round(conv);
X = conv/10000;

conv = Y*10000;
conv = round(conv);
Y = conv/10000;

conv = Z*10000;
conv = round(conv);
Z = conv/10000;

conv = Xlocal*10000;
conv = round(conv);
Xlocal = conv/10000;

conv = Ylocal*10000;
conv = round(conv);
Ylocal = conv/10000;

conv = Zlocal*1000000;
conv = round(conv);
Zlocal = conv/1000000;

conv = HShift*10000;
conv = round(conv);
HShift = conv/10000;

conv = HShift_local*10000;
conv = round(conv);
HShift_local = conv/10000;

conv = Azimuth*10;
conv = round(conv);
Azimuth = conv/10;

conv = Acceleration_local*10000;
conv = round(conv);
Acceleration_local = conv/10000;

conv = Speed*10000;
conv = round(conv);
Speed = conv/10000;

conv = Speed_local*10000;
conv = round(conv);
Speed_local = conv/10000;

conv = Acceleration*10000;
conv = round(conv);
Acceleration = conv/10000;

conv = TempDef_TL*10;
conv = round(conv);
TempDef_TL = conv/10;

text = 'approx function executed correctly';
fprintf(fileID,fmt,text);
fclose(fileID);

end