How to optimize a function using fminunc with 3 unknown variables and many dependent variables
古いコメントを表示
Hi everyone,
I want to find a robot location in an occupancy grid with known pose, I tried to estimate the robot location (with 3 unknown variables of x,y and theta) by using fminunc but my code didn’t work, really appreciate if anyone can help.
x0=[12,8,pi/3]; %initial guess of robot location robotPose = [x0]; intsectionPts= rayIntersection(map,robotPose,angles,maxrange,0.9) % find intersection points of laser beam and occupied cell hold on for i=1:6 x(i)=intsectionPts(i,1); y(i)=intsectionPts(i,2); end fun = (sqrt((x(1)-x0(1))^2+(y(1)-x0(2))^2)-4.6669)^2+(sqrt((x(2)-x0(1))^2+(y(2)-x0(2))^2)-0.6075)^2+(sqrt((x(3)-x0(1))^2+(y(3)-x0(2))^2)-0.6734)^2+(sqrt((x(4)-x0(1))^2+(y(4)-x0(2))^2)-1.3216)^2+(sqrt((x(5)-x0(1))^2+(y(5)-x0(2))^2)-4.708)^2+(sqrt((x(6)-x0(1))^2+(y(6)-x0(2))^2)-0.9899)^2 [x,fval] = fminunc(fun,x0)
採用された回答
その他の回答 (1 件)
Doan Khai Do
2019 年 9 月 18 日
0 投票
1 件のコメント
Raunak Gupta
2019 年 9 月 19 日
Hi,
Since fminunc is an unconstrained optimization it will start from the intial point that is given. It will give a point closer to starting point such that the points minimizes the optimization function in its neighborhood. If no such point exist that minimizes the objective function then you may try changing the 'Algorithm' property in options parameter. Even if it doesn’t find any new point other than the starting point then the starting point itself is the point that locally minimizes the objective function.
カテゴリ
ヘルプ センター および File Exchange で Get Started with Optimization Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!