Basically I am trying to change the ticks on the y axis to be different but keep the same x axis ticks on both. I have looked online and through the textbook but was unable to get what I was looking for. I am attempting to label the top figure's y-axis as (-1,0,1,2), the bottom figure as (-0.2,0,0.2,0.4,0.6) and for both figures with an x-axis of (0,0.5,1,1.5,2)
x = linspace(0,2)
y1 = sin(2*pi*x);
y2 = exp(-0.5*2*pi*x).*sin(2*pi*x);
figure
subplot(2,1,1);
plot(x,y1,'rs')
subplot(2,1,2);
plot(x,y2,'k*')
Here is a way to do it. You need to change the
YTick
andXTick
properties of the axes, as well as theYLim
property for the top plot, since by default Matlab tries to fit the axis with the range of data you have.Which looks like this: