Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: VERY STRANGE LSQCURVEFIT RESULT
Date: Wed, 28 Oct 2009 16:26:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 46
Message-ID: <hc9rap$29n$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256747162 2359 172.30.248.37 (28 Oct 2009 16:26:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 28 Oct 2009 16:26:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1608486
Xref: news.mathworks.com comp.soft-sys.matlab:580664


Hi there,

Using the code below lqscurvefit produces a net error of  0.00812. However when one looks at the fitted curve and compares it with the curve being fitted it is clear that they are massively different due to the second term.

Can anyone explain this apparent error?

%[cn,error]=lsqcurvefit(@PrimePerm3,c0,xdata3,ydata3,lbn,ubn,options);
[cn,error]=lsqcurvefit(@PrimePerm3,c0,xdata,ydata,lbn,ubn,options);

y=PW(xdata2,ydata2,cn(5),cn(6),cn(7),cn(8),cn(9));
params = y';
%params= [cn(1) cn(2) cn(3) cn(4) ];
params=[params cn(5) cn(6) cn(7) cn(8) cn(9)];
y=CRM(xdata3,params);
error2=(y-ydata3).^2;
error2 = sum(error2);
%Res(z,:) = [cn params error error2];
Res(1,:) = [cn params error error2];
%end

optim=find(Res(:,20)==min(Res(:,20)));
toc;
% cn=zeros(n,3); error=zeros(n,1);
% 
% for i=1:n
% % add noise
% NoisyS(i,:) = noise(y,noiselevel,I0);
% 
% % digitizing the signal
% DigiS = digi(NoisyS(i,:),bits);
% 
% % error introduced by both noise and digitization
% substraction(i,:) = DigiS - y;
% 
% % datafitting
% [cn(i,:),error(i)]=lsqcurvefit(@singleexp,c0,x,DigiS,lbn,ubn,options);
% end
 

 
ydata: 4.30000000000000 4.57000000000000 4.78000000000000 4.94000000000000 5.09000000000000 5.23000000000000 5.36000000000000 5.46000000000000 5.52000000000000 5.64000000000000 5.80000000000000 5.92000000000000 5.96000000000000 5.95000000000000

y fitted:
4.30000000000000 -21107.6721741101 4.46147667519652 4.94000000000000 5.13432544641994 5.26732355159549 5.36979229528067 5.45219792241475 5.52000000000000 5.62464324616620 5.73203476147917 5.84087976409200 5.90636658873406 5.95000000000000