MATLAB: Please tell me how to use ode45 code

controltheory

num=134;
den=[1 16 134];
x=tf(num,den)
subplot(1,2,1)
step(x)
title('(a)')
I want to express this code as ode45, how do I do it?

Best Answer

Following is one way of using ode45 to solve this
[t, y] = ode45(@odeFun, [0 1], [0; 0]);
plot(t, y(:,1), 'o-')
function dydt = odeFun(t, y)
% transfer function is equivalent to following ODE
% y'' = -16y'-124y+134u
u = 1; % step input
dydt = zeros(2, 1);
dydt(1) = y(2);
dydt(2) = -16*y(2)-124*y(1)+134*u;
end