function [ y ] = step2( G, t, R ) T = t(2) - t(1); npt = length(t); Gz = c2d(G, T); [Az, Bz, Cz, Dz] = ssdata(Gz); n = length(Az); X = zeros(n,1); y = 0*t; % set the initial condition for i=1:100 X = Az*X + Bz*R(1); end y(1) = Cz*X + Dz*R(1); for i=2:npt X = Az*X + Bz*R(i); Y = Cz*X + Dz * R(i); y(i) = Y; end end