MATLAB: Matlab : 2 x-axis with one plot

matlab axis

Hello, I would like to plot a courb add 2 different x_axis . For the moment, I have only one x_axis and I tried to add an other one but it created also an y_axis but I don't want. My code is :
ax1 = gca;
ax1_pos = ax1.Position;
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'Color','none');
How can I do ? And ho can I choose the scale of the second axis ?
Thank you in advance,
Best regards

Best Answer

I guess that the problem is that the y axis of ax2 overlaps with that of ax1, and the ticks are different. You can remove the ticks of ax2. It should look like there is no additional y axis
set(ax2,'Ytick',[]);
As to the scale on the second (x) axis, you just need to set the xlim property. E.g.
set(ax2,'xlim',[1 2]);
Or, with focus on ax2 ("axes(ax2)") you can use the xlim function
xlim([1 2])