Input data for lsqnonlin
이전 댓글 표시
I'm solving a nonlinear least-squares problem using the lsqnonlin function. What I'm minimizing is the distance between some scattered 3D points(data) and a cylinder. The problem I encountered is on sending the 3D coordinates of the scattered points to the lsqnonlin function. And I need to have the coordinates of these points inside the lsqnonlin because I'm minimizing the distance between the calculated cylinder and the 3D points!
The problem is that, from what I understood, the lsqnonlin function accepts as input ONLY the first guessed value which, inside the lsqnonlin function, will be changed in order to optimize the function. So no space for other, constant input data?!
My optimization call looks like this where W0 is a vector of 3 elements defining the first guess for the cylinder orientation:
lsqnonlin(@Cylind_distance,W0,[-1,-1,-1],[1,1,1]);
The workaround I'm using at the moment is to create the 3D coordinates of the points as global variable, which can then be read inside the Cylind_distance function, but this is not really the best way because of several reasons... Any suggestion?!
채택된 답변
추가 답변 (1개)
Matt J
2015년 4월 8일
0 개 추천
See Passing Extra Parameters
카테고리
도움말 센터 및 File Exchange에서 Choose a Solver에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!