Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!j33g2000cwa.googlegroups.com!not-for-mail
From: wegwerp@gmail.com
Newsgroups: comp.soft-sys.matlab
Subject: Constrained least squares/polynomial fitting
Date: 23 Feb 2006 12:55:14 -0800
Organization: http://groups.google.com
Lines: 36
Message-ID: <1140728114.186592.85140@j33g2000cwa.googlegroups.com>
NNTP-Posting-Host: 82.210.115.118
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1140728119 12465 127.0.0.1 (23 Feb 2006 20:55:19 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 23 Feb 2006 20:55:19 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: j33g2000cwa.googlegroups.com; posting-host=82.210.115.118;
Xref: news.mathworks.com comp.soft-sys.matlab:332753



Hi Group,

I am trying to find an offset between two sets of data points. Both
sets of data (which are measurement data, rougly the same size) could
be fitted with a certain polynomial:

order = 2;
p1 = polyfit(x1,y1,order);
p2 = polyfit(x2,y2,order);
offset = polyval(p2,0) - polyval(p1,0); % or offset = p2(end) - p1(end)

The offset I am looking needs to be evaluated at x=0

So far so good. In my application, however, I have the additional
knowledge that both datasets originate from the same function, apart
from the offset. I thus want to do the polyfitting, with the constraint
that the all the higher order terms are equal for both sets, and I am
looking for the difference in the 0-th order coefficient. For example:

p1 = [a2,a1,a0]
p1 = [b2,b1,b0]

constraint: a2 = b2, a1=b1 and I am looking for b0-a0. It would be nice
to know a1 and a2 too, but that is not neccessary. The polynomial order
will probably be between 1 and 4

Any thoughts or any pointers on how to solve this? I know it should be
straightforward to implement this with fminsearch, but since both
datasets could be large this might be really slow. I do have the
gut-feeling that what I am looking for is a linear problem which could
be solved directly. It has been a long time ago that I had those linear
algebra classes ...

Many thanks in advance,
Bas