Input data for lsqnonlin
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?!
0 commentaires
Réponse acceptée
Torsten
le 8 Avr 2015
lsqnonlin(@(x)Cylind_distance(x,arg1,arg2,...),W0,[-1,-1,-1],[1,1,1]);
where arg1, arg2,... are arguments to Cylind_distance supplied by the user.
Best wishes
Torsten.
0 commentaires
Plus de réponses (1)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!