function output = intp(input1, input2, fun_f, state_old, step_size)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% function output = intp(input1, input2, fun_f, state_old, step_size)
%%
%% Creators Kittiphan Techakittiroj
%% Created 4 May 1996 (at ESCI, Case Western Reserve University)
%% Modified 5 May 1996 (at ESCI, Case Western Reserve University)
%% MATLAB version 4.2c (it should work with the lower version also because
%% there is no special command except the sensitive case function name)
%%
%% This function is the continuous-time simulation of a MIMO co-state equation
%% of continuous-time system by using the Euler Explicit Method
%% The time of simulation assume to be from 0 to size of input-1.
%%
%% Output: output The output from simulation
%% Input: input The input to the system (vector)
%% fun_f The state differential function of the system (file with
%% three arguments, state, input and time)
%% state_old The initial condition of state
%% step_size The step size in the algorithm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
output = zeros(length(state_old), length(input1));
output(:,length(input1)) = state_old;
%% Negative Sign for Back-ward Integration
for k = 2:length(input1),
n = length(input1)+2-k;
output(:,n-1) = output(:,n) ...
-step_size*feval(fun_f, output(:,n), input1(:,n), ...
input2(:,n), n*step_size);
end;