Calculation of the response of strictly proper SISO systems by the convolution integral

response.m

function y=response(num,den,t,u)
%Program for calculation of the response of strictly proper SISO systems
%to arbitrary input by the convolution integral.
%num = numerator polynomial coefficients of transfer function
%den = denominator polynomial coefficients of transfer function
%(Coefficients of 'num' and 'den' are specified as a row vector, in
%decreasing powers of 's')
%t = row vector of time points (specified by the user)
%u = vector of input values at the time points contained in t.
%y = calculated response
%Calculate the time-step:-
dt=t(2)-t(l);
m=size(t,2)
tf=t(m);
%Calculate the convolution integral:-
y=zeros(size(t));
G=y;
[g,T]=impresp(num,den,t(1),dt,tf);
for i=1:m
y=y+dt*u(i)*[G(1:i-1) g ( 1 : m - i + 1 ) ] ;
end