From: "Tom Lane" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: multiple variable exponential regression
Date: Wed, 6 Nov 2013 12:30:21 -0500
Organization: MathWorks
Lines: 17
Message-ID: <l5dubd$a97$>
References: <l58snn$ikv$>
Reply-To: "Tom Lane" <>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
X-Trace: 1383759021 10535 (6 Nov 2013 17:30:21 GMT)
NNTP-Posting-Date: Wed, 6 Nov 2013 17:30:21 +0000 (UTC)
In-Reply-To: <l58snn$ikv$>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: comp.soft-sys.matlab:804898

> I was using other nonlinear regression methods but was getting an 
> imaginary solution (a+ib) form
> modelfun = @(b, x)((100 - 15*(x(2, :).^b(1)))) - (40*((x(3, :).^b(2)))) - 
> (15*((x(4, :).^b(3)))) x = TestData;
> y = x(1, :);
> [beta, R, J, CovB, MSE] = nlinfit(x, y, modelfun, beta0, opts);

One thing I see here is that you have not removed the y column from x, so 
x(1,:) will refer to the same thing as y. In general, if you have any 
negative x values this could yield imaginary results as the nlinfit function 
manipulates the b values. You could use abs() in your modelfun to avoid 
that, but I don't know if that makes sense in your application.

-- Tom