On 04/07/2016 04:54 AM, Francesco
Potortì wrote:
You include a code example, but you should also tell what happens when
you run it and how the outcome is different from what you expect.
Right, and the OP is more likely to get help if they simplified the
problem. I have something to do that I don't particularly like, so
I took the opportunity to procrastinate and pare down their case to
the following:
M=[ 0.5 0; 1.1 0.2; 1.6 .3]
Mt=@(t,p) p(1) * (p(2) - p(3)*exp(-((p(4)*(t+p(5))).^p(6))))
pin=[1; 1; 1; 0.1; 0; 0]
leasqr(M(:,1), M(:,2), pin, Mt);
which displays the error you reported ("weighted residuals are not
real")
I think it must be the fitted function Mt: apparently the way it's
invoked by leasqr it generates 'not real' or Inf/NaN values
for some values of the parameters (I also got "cannot take SVD of
matrix containing Inf or NaN values" errors).
I didn't look in detail at the domain of their function; is it
possible that it generates imaginary or NaN values for parameters
close to your 'pin' values?