Thread Subject: VERY STRANGE LSQCURVEFIT RESULT

Subject: VERY STRANGE LSQCURVEFIT RESULT

From: Hugh

Date: 28 Oct, 2009 16:26:02

Message: 1 of 1

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

 

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
lsqcurvefit Hugh 28 Oct, 2009 12:29:07
incorrect result Hugh 28 Oct, 2009 12:29:07
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com