Minimize difference in vectors by varying scalar

12 views (last 30 days)
I am trying to use fmincon to minimize an equation of the form Smallest_difference(n) = Normal(n) - Altered(n). The Altered(n) vector is meant to be varied by changing one variable, say x, using fmincon. I am using fmincon because x has bounds of 0 < x < 0.25. Also, the minimum value of Smallest_difference(n) will be found at a single x value.
I'm trying to use this optimization to find a spot on the foot where a person's natural gait is least impacted if weight is added. Smallest_difference would be the difference between the normal gait and the altered gait, and would be found for a single value of x. X represents the length from the ankle to the added weight.
I tried to run the optimization and realized that fmincon only minimizes objective functions that return a scalar. Is there any way to get around this problem, like another constrained optimization function, or a loop?
Thanks!

Accepted Answer

Matt J
Matt J on 1 Apr 2018
Edited: Matt J on 1 Apr 2018
If your only constraints are bounds, you can use lsqnonlin() or lsqcurvefit() instead.
Or you could still use fmincon, but scalarize the objective function yourself
TOTAL_difference = norm( Normal - Altered ).^2

More Answers (0)

Community Treasure Hunt

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

Start Hunting!