% Try this code
.
.
.
figure(2);
%set(gcf,'PaperUnits','centimeters'); % Printed figure properties
%set(gcf,'PaperSize', [36 17]);
%set(gcf,'PaperPosition',[0.1 0.1 35.8 16.8]);
plot(X,Z,'b-','LineWidth',2);
grid on
grid minor
title([i,' X-Z ']);
xlabel('X(m)');
ylabel('Z(m)');
Xmax11 = Xmax1 + mod(Xmax1,10000); % Tick gap
set(gca,'XTick',0:5000:Xmax11);
saveas(gcf,[i, ' X-Z.png']);
%print ('-painters','-dpng','-r300',[i, ' X-Z.png']);
.
.
.