MATLAB: How to use fminsearch with several parameters in the right way

fminsearchoptimization

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.

Best Answer

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.