No itterations performed when running lsqcurvefit

2 views (last 30 days)
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.

Answers (1)

Matt J
Matt J on 31 Jan 2014
Edited: Matt J on 31 Jan 2014
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 Comments
Charlotte Beach
Charlotte Beach on 5 Feb 2014
I think I've managed to solve the problem and get the code working now. Thanks very much for your help.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!