Thread Subject: lsqcurvefit

Subject: lsqcurvefit

From: Hugh

Date: 15 Oct, 2009 10:04:04

Message: 1 of 1

Hi,

Ideally I am trying to get a handle on how each of the parameters in the input vector c0 affects teh final result.

I am finding that for the following code leads to quite different solutions for even small pertubations of a given input parameter. Worse that this the residual error does not vary in montone way indeed lows may be found at what appears to be random points within the search zone. which doesn't innspire great confidence that the true global minimum may well lie with some other set of start parameters.

Also I am aware that inputtig different combinations of input parameters can give quite different answers. Ovbiously with 9 different input parameters the permutations quickly become quite prohibitive.

Is the code I am currently using the best way to tackle such a problem if not how could I improve it?

Another point is that sometimes the lsqcurve seems to get stuck? Is there anyway to make it "skip" a given set of input parameters after a given amount of time?


%% datafitting parameters
clc
close all
clear screen
data= dlmread('yield2.txt','\t');
ydata=data(2:end,:);
k=size(ydata);
for i=1:k(1)
xdata(i,:)=data(1,:);
end

xdata2=[2 5 10 30];

ydata2=[4.21 4.6725 5.2375 5.715];

xdata3=data(1,:);
ydata3=data(2,:);

lbn = [-Inf -Inf -Inf -Inf -Inf -6.54722]; % lower bound
ubn = [Inf Inf Inf Inf Inf -6.54720]; % upper bound
options = optimset('LargeScale','on','MaxFunEvals',100000,'TolFun',1e-5,'MaxIter',10000 );

z=0;
for (i=5:0.5:25)

c0 = [1 1 1 1 1 -6.54721 i 0.9 0.9];

z=z+1;
% datafitting
[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=[params cn(5) cn(6) cn(7) cn(8) cn(9)];
y=CRM(xdata3,params)
Res(z,:) = [cn error];
end

optim=find(Res(:,10)==min(Res(:,10)));
 
function F= PrimePerm3(c0,xdata)

F = c0(1)+c0(2)*c0(5)*(1-exp(-xdata./c0(5)))./(xdata) + c0(3)*(1-exp(-((xdata-c0(6)).^2)/c0(7)))./(((xdata-c0(6)).^2)/c0(7))+ c0(4)*(1-exp(-((xdata-c0(8)).^2)/c0(9)))./(((xdata-c0(8)).^2)/c0(9));

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
lqscurvefit Hugh 15 Oct, 2009 06:09:09
unstable parame... Hugh 15 Oct, 2009 06:09:09
infinite loops Hugh 15 Oct, 2009 06:09:09
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