% Funzione che approssima il dato alla quarta cifra decimale (decimi di
% millimetri)
function [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)

text = 'approx_PCL function started';
fileID = fopen(FileName,'a');
fmt = '%s \r';
fprintf(fileID,fmt,text);

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

% Y local
conv = Ylocal_PCL*10000;
conv = round(conv);
Ylocal_PCL = conv/10000;

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

% Z local
conv = Zlocal_PCL*10000;
conv = round(conv);
Zlocal_PCL = conv/10000;

% TempDef
conv = TempDef_PCL*10;
conv = round(conv);
TempDef_PCL = conv/10;

% Accelerazione
conv = acceleration_local_PCL*10000;
conv = round(conv);
acceleration_local_PCL = conv/10000;

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

% Velocità
conv = speed_local_PCL*10000;
conv = round(conv);
speed_local_PCL = conv/10000;

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

% Angoli
conv = AlfaY_PCL*10000;
conv = round(conv);
AlfaY_PCL = conv/10000;

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

text = 'approx_PCL function executed correctly. approx_PCL function closed';
fprintf(fileID,fmt,text);
fclose(fileID);
end
