Wednesday, December 15, 2010

Problem minimizing function in Matlab (fmincon)

Programmer Question

Hi everyone,



I have a function which calculates the acoustic strength of a fish depending on the incident angle of the wavefront on the fish. I also have some in situ measurements of acoustic strength. What I'm trying to do is figure out which normal distribution of angles results in the model data matching up most closely with the in situ data.



To do this, I'm trying to use the Matlab function fmincon to minimize the following function:



function f = myfun(x)

TS_krm = KRM(normrnd(x(1),x(2),100,1), L);
f = sum((TS_insitu - TS_krm).^2);


So what this function does is calculates the sum of squared residuals, which I want to minimize. To do this, I try using fmincon:



x = fmincon(@myfun, [65;8], [], [], [], [], [0;0], [90;20], [], options);


Thus, I'm using a starting orientation with a mean of 65 degrees and a standard deviation of 8. I'm also setting the mean angle bounds to be from 0 to 90 degrees and the standard deviation bounds to be from 0 to 20 degrees.



Yet it doesn't seem to be properly finding the mean and standard deviation angles which minimize the function. Usually it outputs something right around N(65,8), almost like it isn't really trying many other values far from the starting points.



Any ideas on what I can do to make this work? I know I can set the TolX and TolFun settings, but I'm not really sure what those do and what effect they'd have. If it helps, the typical values that I'm dealing with are usually around -45 dB.



Thanks!



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails