function R=modres(p,xr,xp,c,t,obsdata)
% called by rtl - returns difference between observed data 
% and predicted data from kinetic model
	x=xp-xr;
	p=abs(p);
	tmp_xr=size(xr);
%	f= @(c,t) transpose(x)*(p.*prod(repmat(transpose(c),rows(xr),1).^xr,2)); #anonymous function describing the ratelaws, for octave
	cfunc= @(t,c) transpose(x)*(p.*prod(repmat(transpose(c),tmp_xr(1),1).^xr,2)); %anonymous function describing the ratelaws, formatlab

%	C=lsode(f,c,t); # anonymouns function returning concentrations as a function of time, for octave
	[junk,C]=ode45(cfunc,t,c); % anonymouns function returning concentrations as a function of time, for matlab
	R=obsdata-C*pinv(C)*obsdata;
	R=sum(sum(sqrt(R.^2)));
end
