|
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));
|