% Demo of subplot function

% Problem: describes the motion of a small building subject to a seismic
% force

% x - time domain in seconds
% y - building displacement (centimeters)

x = 0:0.01:10;           
y = sin(x.^2).*exp(-x);
z=gradient(y,x);

subplot(2,1,1)		% generates top plot		
plot(x,y)
xlabel('Time (s)','FontSize',26)
ylabel('Displacement (cm)','FontSize',26)
grid

subplot(2,1,2)		% generates lower plot
plot(x,z)
xlabel('Time (s)','FontSize',26)
ylabel('Speed (cm/s)','FontSize',26)
grid