%simulation error function
function err = loc_err(x,m,j,n_r);

l=m.description{j}.linears;
	
for i=1:n_r,
	l(:,1,end-n_r+i)=x(2);
	l(:,end,end-n_r+i)=l(:,end,end-n_r+i)+x(1);
end

set(m,{j 'linears'},l);

err=simulation_error(m,j)/1e6;
	
