In order to calculate the mean, the y-coordinate data would have to be interpolated to the same x-coordinate values, those spanning the lowest to the highest values of your x-coordinates. Once you have done that, you would use the nanmean function (or mean with the 'omitnan' argument) to get the mean.
The reason to use nanmean is that the y-values of the shorter steps would be NaN outside their normal x-coordinate ranges (the usual result of interp1 if not extrapolation method is specified, and here you do not want to extrapolate), so nanmean would give the correct values for the mean.
So the code would go something like this:
xvals = linspace(min(x), max(x), 1000);
yvals = interp1(x, y, xvals);
ymean = mean(yvals, dim, 'omitnan');
where ‘dim’ is the dimension you want to take the mean with respect to. (We do not have your data, so we cannot determine that.) The ‘ymean’ output should be what you want, defined at every value of ‘xvals’.