What's the problem with yticks(0:5:Max+10)?
DisplayNumber(0:9,100*rand(1,10),100*rand(1,10),'output.pdf','')
function DisplayNumber(x,y1,y2,Name,Method)
plot(x,y1,'-s','MarkerSize',9,...
'MarkerEdgeColor','green',...
'MarkerFaceColor',[0 0.4470 0.7410])
hold on
% legend({'cos(x)','cos(2x)','cos(3x)','cos(4x)'},...
% 'Location','northwest','NumColumns',2)
p=plot(x,y2,'-s','MarkerSize',9,...
'MarkerEdgeColor','yellow',...
'MarkerFaceColor',[0.6350 0.0780 0.1840]);
hold off
xtickangle(0)
max(y1);
Max= max( max(y1),max(y2));
ylim([0 Max+10]);
yticks(0:5:Max+10)
Max=max(x);
xlim([1 Max+1]);
legend( strcat(Method,"-AHP"),strcat(Method,"-MOWOA-NIS"));
ylabel('Rank reversal ratio %');
xlabel('Number of networks');
xticks(0 : 20)
grid on
set(gcf,'Units','Inches');
pos = get(gcf,'Position');
set(gcf,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)])
print(gcf,Name,'-dpdf','-r0')
end