I defined a function that I call disc which I want to minimize later. The function is defined as
disc[dt_]:=Total[(Log[vDat] - Log[(x'[tDat -dt] /. nsol)])^2]
and it quantifies the discrepancy between measured data (the time series {tDat,vDat}) and the solution to a differential equation that was obtained with NDSolve.
My problem is that this function works great sometimes:

but fails in other applications:

I tried hard to get to the bottom of this, but I just can't understand what's wrong. Suggestions?
Clarification: disc[1] returns a number and not a {number}.


disc[]:disc[dt_?NumericQ] := (* stuff *). – J. M.♦ Aug 14 '12 at 10:24tDat,vDat, andnsol... – J. M.♦ Aug 14 '12 at 10:34disc[sol_,dt_]and I have to give it the interpolating function too. I omitted that in the post for clarity. – yohbs Aug 14 '12 at 11:26