To my understanding, there is no error in the output of this MATLAB code. Contours are plotted at right locations, as visible in this figure.
To fix this, you may try the following:
- Either modify your expression for a so that contours are generated with matching values of x-ticks, or
- You can change the x-ticks to match the contour data points.
Here is the modified code
numpress1 = numel(press1);
a(i,j) = temp1(i)+40.*log((1/1050).*press1(j));
press1 = transpose(press1);
temp1 = transpose(temp1);
temp2 = [-130 -120 -110 -100 -90 -80 -70 -60 -50 temp1'];
b = contour(temp1,press1,a,temp2,'k','ShowText','on');
set(gca,'yscale','log','ydir','reverse')
set(gca,'ytick',100:50:1050)
Refer MATLAB Documentation on contour function which provides instructions to control number of contour lines displayed and there values. https://www.mathworks.com/help/matlab/ref/contour.html#d124e233677
Hope it helps.