function output = intx(input, fun_f, state_old, step_size)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% function output = intx(input, 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 continuous-time
%% system by using 4th Runge-Kutta
%% 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(input));
output(:,1) = state_old;
for n = 2:length(input),
output(:,n) = output(:,n-1) + ...
step_size*feval(fun_f, output(:,n-1), input(:,n-1), (n-1)*step_size);
end;