I wasn’t sure to be allowed to post the code here, that’s why I didn’t provide you with it earlier.

In the code, use xyz_coordinates_RIGHT.csv (198.2 KB) instead of

`"xyz_coordinates_RIGHT.mat"`

Here there is the code:

```
load("xyz_coordinates_RIGHT.mat")
figure
plot3(xyz_coord_RIGHT(:,1),xyz_coord_RIGHT(:,2),xyz_coord_RIGHT(:,3),'bs');
[xq_R,yq_R] = meshgrid(min(xyz_coord_RIGHT(:,1)):0.1:max(xyz_coord_RIGHT(:,1)),min(xyz_coord_RIGHT(:,2)):0.0005:max(xyz_coord_RIGHT(:,2)));
[Xq_R,Yq_R,vq_R] = griddata(xyz_coord_RIGHT(:,1),xyz_coord_RIGHT(:,2),xyz_coord_RIGHT(:,3),xq_R,yq_R);
figure
surf(xq_R,yq_R,vq_R)
pbaspect([10 1 10])
z_RIGHT_mean= mean(xyz_coord_RIGHT(:,1));
z_RIGHT_std= std(xyz_coord_RIGHT(:,1));
figure
[f_RIGHT,xi] = ksdensity(xyz_coord_RIGHT(:,3));
plot(xi,f_RIGHT)
hold on
h_RIGHT = histogram(xyz_coord_RIGHT(:,3),'BinWidth',0.01,'Normalization','pdf');
plot(xi,h_RIGHT)
hold off
ypos_RIGHT= xyz_coord_RIGHT(:,2);
A_RIGHT= xyz_coord_RIGHT(ypos_RIGHT==65.9820000000000,:);
Atab_RIGHT = array2table(A_RIGHT);
Atab_RIGHT.Properties.VariableNames(1:3) = {'X', 'Y', 'Z'};
B_RIGHT= sortrows(A_RIGHT);
B_RIGHT= B_RIGHT(1:end-3, 1:3);
B_RIGHT_Zcoord= B_RIGHT(:,3); %USELESS
Zmin_RIGHT= min(B_RIGHT_Zcoord); %USELESS
Zmax_RIGHT= max(B_RIGHT_Zcoord); %USELESS
B_RIGHT_Xcoord= B_RIGHT(:,1); %USELESS
Xmin_RIGHT= min(B_RIGHT_Xcoord); %USELESS
Xmax_RIGHT= max(B_RIGHT_Xcoord); %USELESS
n= size(B_RIGHT,1);
start= 1;
for i=1:n-1
if (B_RIGHT(i+1,1)-B_RIGHT(i,1)) > 0.01
C_RIGHT(start,:)= B_RIGHT(i,:);
start= start+1;
end
end
x_grid_RIGHT = min(C_RIGHT(:,1)):0.5:max(C_RIGHT(:,1));
x_grid2_RIGHT = min(C_RIGHT(:,1)):0.1:max(C_RIGHT(:,1));
F_RIGHT = griddedInterpolant(C_RIGHT(:,1),C_RIGHT(:,3), 'spline');
V_RIGHT= F_RIGHT(x_grid_RIGHT);
figure
plot(x_grid_RIGHT,V_RIGHT,'--bs'); %'--ro'
grid on
xlabel('X-longitudinal [m]')
ylabel('Z [m]')
title('Right side')
colors={'g','r','c','k'};
figure
plot(x_grid_RIGHT(4:end-3),V_RIGHT(4:end-3),'bs');
hold on
for pp=1:4
[P_RIGHT,S_RIGHT]= polyfit (x_grid_RIGHT(3:end-3),V_RIGHT(3:end-3),pp);
nr(pp,1)= S_RIGHT.normr;
V2_RIGHT= polyval(P_RIGHT,x_grid2_RIGHT(:));
plot(x_grid2_RIGHT(15:end-15),V2_RIGHT(15:end-15),'--','Color',colors{pp});
hold on
end
legend('filtered PC points','grade 1', 'grade 2', 'grade 3', 'grade 4')
pp1=1;
[P1_RIGHT,S1_RIGHT]= polyfit (x_grid_RIGHT(3:end-3),V_RIGHT(3:end-3),pp1);
pp2=2;
[P2_RIGHT,S2_RIGHT]= polyfit (x_grid_RIGHT(3:end-3),V_RIGHT(3:end-3),pp2);
pp3=3;
[P3_RIGHT,S3_RIGHT]= polyfit (x_grid_RIGHT(3:end-3),V_RIGHT(3:end-3),pp3);
pp4=4;
[P4_RIGHT,S4_RIGHT]= polyfit (x_grid_RIGHT(3:end-3),V_RIGHT(3:end-3),pp4);
```

Thank you for your previous reply.