No itterations performed when running lsqcurvefit

3 次查看(过去 30 天)
I'm attempting to run experimental data through the isqcurvefit tool in order to obtain a value for alpha from my fit. The function I'm trying to fit approximates to is a summation but it works accurately for four summations so I've actually written it out to this order as the function. The function is:
function F = alpcal(alpha, t)
F = 1 + 2*(((-1).^(1)).*exp(-((1.^2).*(pi^2).*(alpha.*t))/((1e-3)^2))) + ...
1 + 2*(((-1).^(2)).*exp(-((2.^2).*(pi^2).*(alpha.*t))/((1e-3)^2))) + ...
1 + 2*(((-1).^(3)).*exp(-((3.^2).*(pi^2).*(alpha.*t))/((1e-3)^2))) + ...
1 + 2*(((-1).^(4)).*exp(-((4.^2).*(pi^2).*(alpha.*t))/((1e-3)^2)));
For each run I obtain:
Norm of First-order
Iteration Func-count f(x) step optimality CG-iterations
0 2 7340.11 0
Initial point is a local minimum.
Optimization completed because the size of the gradient at the initial point
is less than the selected value of the function tolerance.
in the command window.
This is the attempt I've made to correct this, but it hasn't made any difference, I continue to get that result.
options = optimset('DiffMinChange',1e-3,'disp','iter','TolFun',1e-5, ...
'DiffMaxChange',1);
% Anaonomous function to allow for more parameters to be passed to the
% function
A = @(alpha, t)alpcal(alphat, t, L);
% Determines the value of alpha from the x and y data and function A
[alp,resnorm,residual,exitflag] = lsqcurvefit(A, alphat, t, y);
I can't say that I understand entirely what the options functions do, so I'm stabbing in the dark a bit at the moment and going off what I've managed to find after extensive internet searching. But if anyone can let me know where I'm going wrong it would be greatly appreciated as I've spent quite some time searching.

回答(1 个)

Matt J
Matt J 2014-1-31
编辑:Matt J 2014-1-31
You should attach your t,y data in a .mat file so we can test it. However, you would have to be careful with your initial guess of alpha to be sure the exponentials don't overflow. I would recommend rewriting your objective as follows
T=max(abs(t));
F = 1 + 2*((-1).^(1)).*exp(-(1.^2).*alpha.*t/T ) + ...
1 + 2*((-1).^(2)).*exp(-(2.^2).* alpha.*t/T ) + ...
1 + 2*((-1).^(3)).*exp(-(3.^2).* alpha.*t/T ) + ...
1 + 2*((-1).^(4)).*exp(-(4.^2).*alpha.*t/T );
and use alphat=1. You can rescale alpha as you see fit later, after lsqcurvefit gives you an estimate of it.
  8 个评论
Charlotte Beach
Charlotte Beach 2014-2-5
I think I've managed to solve the problem and get the code working now. Thanks very much for your help.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Least Squares 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by