<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264338</link>
    <title>MATLAB Central Newsreader - VERY STRANGE LSQCURVEFIT RESULT</title>
    <description>Feed for thread: VERY STRANGE LSQCURVEFIT RESULT</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 28 Oct 2009 16:26:02 -0400</pubDate>
      <title>VERY STRANGE LSQCURVEFIT RESULT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264338#690347</link>
      <author>Hugh </author>
      <description>Hi there,&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
Can anyone explain this apparent error?&lt;br&gt;
&lt;br&gt;
%[cn,error]=lsqcurvefit(@PrimePerm3,c0,xdata3,ydata3,lbn,ubn,options);&lt;br&gt;
[cn,error]=lsqcurvefit(@PrimePerm3,c0,xdata,ydata,lbn,ubn,options);&lt;br&gt;
&lt;br&gt;
y=PW(xdata2,ydata2,cn(5),cn(6),cn(7),cn(8),cn(9));&lt;br&gt;
params = y';&lt;br&gt;
%params= [cn(1) cn(2) cn(3) cn(4) ];&lt;br&gt;
params=[params cn(5) cn(6) cn(7) cn(8) cn(9)];&lt;br&gt;
y=CRM(xdata3,params);&lt;br&gt;
error2=(y-ydata3).^2;&lt;br&gt;
error2 = sum(error2);&lt;br&gt;
%Res(z,:) = [cn params error error2];&lt;br&gt;
Res(1,:) = [cn params error error2];&lt;br&gt;
%end&lt;br&gt;
&lt;br&gt;
optim=find(Res(:,20)==min(Res(:,20)));&lt;br&gt;
toc;&lt;br&gt;
% cn=zeros(n,3); error=zeros(n,1);&lt;br&gt;
% &lt;br&gt;
% for i=1:n&lt;br&gt;
% % add noise&lt;br&gt;
% NoisyS(i,:) = noise(y,noiselevel,I0);&lt;br&gt;
% &lt;br&gt;
% % digitizing the signal&lt;br&gt;
% DigiS = digi(NoisyS(i,:),bits);&lt;br&gt;
% &lt;br&gt;
% % error introduced by both noise and digitization&lt;br&gt;
% substraction(i,:) = DigiS - y;&lt;br&gt;
% &lt;br&gt;
% % datafitting&lt;br&gt;
% [cn(i,:),error(i)]=lsqcurvefit(@singleexp,c0,x,DigiS,lbn,ubn,options);&lt;br&gt;
% end&lt;br&gt;
&amp;nbsp;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&lt;br&gt;
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&lt;br&gt;
&lt;br&gt;
y fitted:&lt;br&gt;
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&lt;br&gt;
&lt;br&gt;
&amp;nbsp;</description>
    </item>
  </channel>
</rss>

