% First, create the plots from cartpole_hw1a:

cartpole_hw1a  % Run the other script, to get figures


% ---------- Simulate linear dynamics; plot results. -------
[tnonlin,Xnonlin] = ode45(@cartpole_nonlinear,[0 Tfinal],X0);

figure(1); % 
subplot(211)
plot(tnonlin,Xnonlin(:,1),'r--'); % plot theta(t)
legend('linear','nonlinear')

subplot(212)
plot(tnonlin,Xnonlin(:,2),'r--'); % plot theta(t)
legend('linear','nonlinear')

orient tall % to use full page when printing out the figure
