Clear Filters
Clear Filters

How to use fminsearch with several parameters in the right way?

6 views (last 30 days)
Hello,
it is the first time that I try use some optimization and somebody told me it is a good idea to use fminsearch?
Aim:
I got a function sumDist = transDist(feat1, feat2, tP) and I want to optimize it:
y = fminsearch (@(x) transDist(this.featP1, this.featP2, x), 0);
0 would be the optimal result of the function but it is like unreachable. x is an vector of size 9 where value 4 to 6 are angles in radians, don't know if i need to limit the value range and how i could do this. As result i would like to get the x vector for the best result fminsearch was able to find.
I hope you can help me a little bit with that.
Thank you in advance.
Greetings,
me
@Edit1 (2016-07-08 08:17:00) fminsearch should be fine but 1 thing I noticed in the first comment is
x0 = zeros(9,1);
but I don't know what a good value for the input could be. I only know that 0 as a result would be the best possible solution for the output. My function calculates a scaling, rotation, transformation in 3D until featP1 fit best to featP2. Could you help me solve this problem, because if this doesn't work I got no Idea how to make it work.
  5 Comments
Walter Roberson
Walter Roberson on 7 Jul 2016
fminsearch does not get "confused" by multiple identical optimum: it just randomly ends up in one of the basins.
Walter Roberson
Walter Roberson on 8 Jul 2016
If you have no idea what a good starting point is, then you might as well pick a value at random out of the entire range of values possible for that position. For example,
RR = @(A,B) A + rand()*(B-A);
x0 = [RR(-500,750), RR(0, realmax), RR(-pi,pi), RR(-pi,pi), RR(-pi,pi)];
This would construct a vector in which the first element was chosen uniform randomly over (-500,750), the second over (0, 1E+308), and the other three over -pi to +pi.
And then if you don't get a nice result, you can randomly generate again...

Sign in to comment.

Accepted Answer

baxbear
baxbear on 10 Jul 2016
x0 = zeros(9,1);
and
x0 = rand(9, 1);
are the best ways to use my matlab function, 0 does not work because then fminsearch does not know that I am looking for a vector of size 9.
  2 Comments
Marc
Marc on 11 Jul 2016
This is not an "accepted" answer to the question. Nobody knows what you are looking for because your question was pretty vague. There are well known reasons why a Nelder Mead Simplex approach works and doesn't work. There is also a good reason why The Mathworks Co. sells an Optimaztion and Global Optimaztion toolbox.
Walter Roberson
Walter Roberson on 11 Jul 2016
The poster Accepted their own Answer, so it was an answer that served their purpose. (It was pretty much the answer the volunteers had described.)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!