I can fit part of your data, however not all of it, because there is some noise in elements 19 through 24 that your function is likely to not able to account for. (I had to eliminate the commas from your data and translate them into decimal points. Thjat worked for the data you posted, however I do not know if it will work for your entire vector.)
Try this:
X = string([0,301067677000000
0,314157576000000
0,327247475000000
0,340337374000000
0,353427273000000
0,366517172000000
0,379607071000000
0,392696970000000
0,405786869000000
0,418876768000000
0,431966667000000
0,445056566000000
0,458146465000000
0,471236364000000
0,484326263000000
0,497416162000000
0,510506061000000
0,523595960000000
0,536685859000000
0,549775758000000
0,562865657000000
0,575955556000000
0,589045455000000
0,602135354000000]);
Y = string([0,0193930890000000
0,0221282684000000
0,0245255339000000
0,0265479770000000
0,0281674962000000
0,0293643273000000
0,0301265743000000
0,0304497403000000
0,0303362581000000
0,0297950211000000
0,0288409140000000
0,0274943436000000
0,0257807698000000
0,0237302359000000
0,0213768998000000
0,0187585647000000
0,0159162099000000
0,0128935212000000
0,00973642228000000
0,00649260510000000
0,00321106079000000
-5,83896230000000e-05
-0,00326556436000000
-0,00636039014000000]);
V = sscanf(sprintf('%s.%s\n',X.'),'%f');
y = sscanf(sprintf('%s.%s\n',Y.'),'%f');
d2 = @(beta,alpha,N,phi,V) (4903985730770845.*N.*(((exp(alpha.*(phi - V.*(beta - 1))) + 1).*((alpha.^2.*beta.^2.*exp(alpha.*...
(phi - beta.*V)))./(exp(alpha.*(phi - V.*(beta - 1))) + 1) - (alpha.^2.*exp(alpha.*(phi - V.*(beta - 1))).*...
(exp(alpha.*(phi - beta.*V)) + 1).*(beta - 1).^2)./(exp(alpha.*(phi - V.*(beta - 1))) + 1).^2 + ...
(2.*alpha.^2.*exp(2.*alpha.*(phi - V.*(beta - 1))).*(exp(alpha.*(phi - beta.*V)) + 1).*(beta - 1).^2)./...
(exp(alpha.*(phi - V.*(beta - 1))) + 1).^3 - (2.*alpha.^2.*beta.*exp(alpha.*(phi - beta.*V)).*exp(alpha.*...
(phi - V.*(beta - 1))).*(beta - 1))./(exp(alpha.*(phi - V.*(beta - 1))) + 1).^2))./(alpha.*(exp(alpha.*(phi - beta.*V))...
+ 1)) + (exp(alpha.*(phi - V.*(beta - 1))).*(beta - 1).*((alpha.*beta.*exp(alpha.*(phi - beta.*V)))./(exp(alpha.*(phi -...
V.*(beta - 1))) + 1) - (alpha.*exp(alpha.*(phi - V.*(beta - 1))).*(exp(alpha.*(phi - beta.*V)) + 1).*(beta - 1))./...
(exp(alpha.*(phi - V.*(beta - 1))) + 1).^2))./(exp(alpha.*(phi - beta.*V)) + 1) - (beta.*exp(alpha.*(phi - beta.*V)).*...
((alpha.*beta.*exp(alpha.*(phi - beta.*V)))./(exp(alpha.*(phi - V.*(beta - 1))) + 1) - (alpha.*exp(alpha.*(phi - V.*...
(beta - 1))).*(exp(alpha.*(phi - beta.*V)) + 1).*(beta - 1))./(exp(alpha.*(phi - V.*(beta - 1))) + 1).^2).*(exp(alpha.*...
(phi - V.*(beta - 1))) + 1))./(exp(alpha.*(phi - beta.*V)) + 1).^2))./63407003003326144512;
Ve = V(1:18);
ye = y(1:18);
ftns = @(b) norm(ye - d2(b(1),b(2),b(3),b(4),Ve));
PopSz = 500;
Parms = 4;
opts = optimoptions('ga', 'PopulationSize',PopSz, 'InitialPopulationMatrix',randi(1E+4,PopSz,Parms)*1E-2, 'MaxGenerations',2E3, 'PlotFcn',@gaplotbestf, 'PlotInterval',1);
t0 = clock;
fprintf('\nStart Time: %4d-%02d-%02d %02d:%02d:%07.4f\n', t0)
[B,fval,exitflag,output] = ga(ftns, Parms, [],[],[],[],[],[],[],[],opts)
t1 = clock;
fprintf('\nStop Time: %4d-%02d-%02d %02d:%02d:%07.4f\n', t1)
GA_Time = etime(t1,t0)
fprintf('\nElapsed Time: %23.15E\t\t%02d:%02d:%02d.%03d\n', GA_Time, hmsdv(GA_Time))
fprintf(1,'\tParameters:\n')
for k1 = 1:length(B)
fprintf(1, '\t\tB(%d) = %8.5f\n', k1, B(k1))
end
xv = linspace(min(Ve), max(Ve), 250);
figure
plot(Ve, ye, 'p')
hold on
plot(xv, d2(B(1),B(2),B(3),B(4),xv), '-r')
grid
producing these parameter estimates:
Parameters:
B(1) = 15.96980
B(2) = 0.63200
B(3) = 542.18665
B(4) = 7.56829
with the elements of ‘B’ being, in order: ‘beta’, ‘alpha’, ‘N’, and ‘phi’. They retain their full precision internally.
and this plot:
Plot images are not showing up with the ‘Picture’ icon for some reason, so I am also attaching the plot image as a separate file to be sure it is visible.
Best Answer