- fminbnd is not just for continuous functions. It should converge to something reasonable if you give it an initial interval where the function is not NaN or Inf or complex.
- Please format your code using the {} Code button so we can read it.
- Even better, try explaining what you are trying to do in words.
problem finding minimum of residual for separable nonlinear least square using fminsearch
4 views (last 30 days)
Show older comments
Dear All, I have some ultrasonic signal that I created wavelet transform for. I am trying to do separable nonlinear least square between measured signal(function of time and frequency) and reference model. to get the maximization criterion I made derivation for different equations and reshaping of the matrix to be a vector instead of a matrix in order to match fminsearch. Please find attached for the equations required to perform for the maximization criterion the final model I needed to maximize is shown below:
I tried to use fminsearch function to get the minimum value of t_center but I can not get any solution. it says: Exiting: Maximum number of function evaluations has been exceeded - increase MaxFunEvals option. I already increased MaxFunEvals and MaxIter to 1000 but still not possible. Please find below the code I made and tell me what is wrong with it. I already attached the m-file for better reading of the code.
function max_criterion = myfun(t_center)
global F s
w=2*pi*F';
t=linspace(0,0.015,3000);
w_center=2*pi*200000;
w1=2*pi;
eeta=w./w1;
Y=s;
B=100000;
A=1/2.*sqrt((2.*eeta)./(pi.*(B^2+4.*eeta.^2)).*exp(-2.*(w-w_center).^2./(B.^2+4.*eeta.^2)));
k= -B.^2.*eeta.^2./(2.*(B.^2+4.*eeta.^2))*(t-t_center).^2;
kai= ((4*w_center*eeta.^2)./(B^2+4.*eeta.^2)+B^2.*w./(B^2+4.*eeta.^2))*(t_center-t);
Z=repmat(A,1,length(t));
H=Z.*exp(k).*exp(1i.*kai);
H_new=(reshape(H,numel(H),1));
Y_new=(reshape(Y,numel(Y),1));
max_criterion= -1000000000.*Y_new'*H_new*((H_new'*H_new)\H_new')*Y_new;
end
then I am trying to use fminsearch function to extract the local minimum but it never give a solution:
options=optimset('tolx',1e-18,'tolfun',1e-18,'MaxFunEvals',1000,'MaxIter',1000);
t_center_ini = 0.000591;
[t_center,fval,exitflag,output] = fminsearch(@myfun,t_center_ini,options)
I tried to use function "fminbnd" and it gave results but I am afraid to use because it works only with continuous functions and may be the wavelet transform have discontinuities.
Can you please help me with that. what is the mistake I do. Best Regards, Hossam Selim
0 Comments
Answers (3)
Alan Weiss
on 26 Jan 2015
Just my suggestions,
Alan Weiss
MATLAB mathematical toolbox documentation
0 Comments
John D'Errico
on 27 Jan 2015
I'm not going to go through your code. HOWEVER, I will point out that I've already written a separable least squares solution that is based on fminsearch. It is on the file exchange, called fminspleas.
Having said that, I also don't know how many nonlinear unknowns you are solving for using these tools. I tend to suggest an upper limit of 6 to at most 8 unknowns. Beyond that point is usually just a waste of CPU time with fminsearch. It may explain why you are having problems though.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!