MATLAB: How to create a uniform y-tick interval in subplots

MATLABsubplotsy intervals

Hello, I am wondering how to create a uniform y tick interval between subplots in matlab, that takes into consideration the ylimits?
Lets say that I only wanted there to be only 4 intervals per plot and only rounded ytick labels apparement, all the precise same position per subplot. I tried to do this calculating the min and max's for each subplot and dividng the absolute difference between each by 4, unfortunately it didn't work out. Below is the graph that is created without any interference by myself. If anyone is familar with TecPlot, I want to make the axis values 'nice'.

Best Answer

Something like this works. Note that you'll have some challenges because most of your y values are very small, so it might not look quite like you'd expect.
p1 = rand([50,1])*5.5-1.1;
p2 = rand([50,1])*3.5e-6 - 3e-6;
p3 = rand([50,1])*0.5e-6 + 3.8e-6;
p4 = rand([50,1])*4.1e-7 - 3e-7;
p5 = rand([50,1])*0.2e-6 - 3.45e-6;
subplot(5,1,1)
plot(p1)
yval = ylim(gca);
set(gca,'YTick',linspace(yval(1),yval(2),5),"YTickLabel",round(linspace(yval(1),yval(2),5)))
subplot(5,1,2)
plot(p2)
yval = ylim(gca);
set(gca,'YTick',linspace(yval(1),yval(2),5),"YTickLabel",round(linspace(yval(1),yval(2),5),6))
subplot(5,1,3)
plot(p3)
yval = ylim(gca);
set(gca,'YTick',linspace(yval(1),yval(2),5),"YTickLabel",round(linspace(yval(1),yval(2),5),6))
subplot(5,1,4)
plot(p4)
yval = ylim(gca);
set(gca,'YTick',linspace(yval(1),yval(2),5),"YTickLabel",round(linspace(yval(1),yval(2),5),7))
subplot(5,1,5)
plot(p5)
yval = ylim(gca);
set(gca,'YTick',linspace(yval(1),yval(2),5),"YTickLabel",round(linspace(yval(1),yval(2),5),6))