function y=modode(t,k)
%function y=modode(t,k)
% example using ode45k to integ	and leasqr to fit ode parameters


%Arthur Jutan 
%Dept of Chemical and Biochemical Enginering
%Univ of Western Ontario
%London Ontario Canada, N6A 5B9

% by global declaration in other subroutines

global  x0_ ;%initial conditions
x0=x0_;
[t1,x]=ode45k('xprime', t,x0,[],k );
% new ode45k  gives solutions at all t values- don't need interpolation
% take second x for output y, this is the one being fitted
y=x(:,2);

% calc spline interpolations at t data points on x(2) only
%y=spline(t1,x(:,2),t) ;	%  spline if few points
%OR
%y=table1([t1,x(:,2)],t); % linear interp if many points
% replace negative conc with small +ve values if apropriate
%i=find(y<0);
%y(i)=0.001*ones(i); %causes problems with leasqr1
