% script file pendulum.m % % solve and plot the inverted pendulum problem defined in InvPend.m % % Dependency % InvPend.m global g; g = 386.09; % constant g global L; global A; global w; L = 10; % length A = input('Anplitude A: '); w = input('Angle speed w: '); tInit = 0; % initial t tFinal = 2.0; % final t yInit = zeros(2,1); % [y(0); (d/dt)y(0)] yInit(1,1) = input('Initial angle: '); % % use default tolerance RelTol = 1e-3 and AbsTol = 1e-6 [t,y] = ode45('InvPend', [tInit tFinal], yInit); % % figure % start a new figure window plot(t, y(:,1)) % plot (t,y) title(sprintf('ODE45 Steps = %5.0f, tol = %5.0e', length(t),tol))