The issue is with "meanplot" implementation. Ideally, if you are doing this:
figure, subplot(2,1,1), plot(1:10)
This should open a new figure and plot the graph on the first axes (subplot(2,1,1)). It is not clear from your code what "meanplot" does and what is the first argument ('1') to the meanplot.
One way you can consider to modify your meanplot definition is to pass the handle to the newly created figure and then modifying the 'XData' and 'YData' properties of the axes handles to the figure. This is efficient but complicated approach.
If I have a functioned defined like this:
function meanplot()
plot(1:10)
end
And then I run the following code, I get two different figures with the subplots:
subplot(211), plot(1:10)
subplot(212), plot(5:15)
figure, subplot(211), meanplot