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);
	f= @(c,t) transpose(x)*(p.*prod(repmat(transpose(c),rows(xr),1).^xr,2)); #anonymous function describing the ratelaws
	C=lsode(f,c,t); # anonymouns function returning concentrations as a function of time
	R=obsdata-C*pinv(C)*obsdata;
	R=sum(sum(sqrt(R.^2)));
endfunction
