% Funzione che approssima il dato alla quarta cifra decimale (decimi di
% millimetri)
function [X_HD,Y_HD,Z_HD,Xlocal_HD,Ylocal_HD,Zlocal_HD,HShift_HD,HShift_local_HD,Azimuth_HD,Speed_HD,...
    Speed_local_HD,Acceleration_HD,Acceleration_local_HD,TempDef_HD] = approx_HD(X_HD,Y_HD,Z_HD,...
    Xlocal_HD,Ylocal_HD,Zlocal_HD,HShift_HD,HShift_local_HD,Azimuth_HD,Speed_HD,Speed_local_HD,...
    Acceleration_HD,Acceleration_local_HD,TempDef_HD,FileName)
        
text = 'approx function started';
fileID = fopen(FileName,'a');
fmt = '%s \r';
fprintf(fileID,fmt,text);

conv = X_HD*100000;
conv = round(conv);
X_HD = conv/100000;

conv = Y_HD*100000;
conv = round(conv);
Y_HD = conv/100000;

conv = Z_HD*100000;
conv = round(conv);
Z_HD = conv/100000;

conv = Xlocal_HD*100000;
conv = round(conv);
Xlocal_HD = conv/100000;

conv = Ylocal_HD*100000;
conv = round(conv);
Ylocal_HD = conv/100000;

conv = Zlocal_HD*10000000;
conv = round(conv);
Zlocal_HD = conv/10000000;

conv = HShift_HD*100000;
conv = round(conv);
HShift_HD = conv/100000;

conv = HShift_local_HD*100000;
conv = round(conv);
HShift_local_HD = conv/100000;

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

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

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

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

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

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

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

end