Clear Filters
Clear Filters

Minimize difference between two data sets

3 views (last 30 days)
I have two data sets, one will not change while the other depends on two variables, say A and B. I have a function that takes A and B, recomputes the one data set using A and B using a seperate function (i.e. it calls another function), then spits out a value for how well the two data sets compare. The function I described works alone (call it my_func). When I try to minimize, is when it fails. I have tried multiple methods: lsqnonlin, fminsearch, and fminunc. All follow a similar format being [output] = [method](@(A,B) my_func(A,B), [A B]) and they all return a failure to continue due to not enough input arguments.
Am I using these methods incorrectly? I am not sure why the will not begin to solve. Is there another method that I am unaware of that would work better for this application? Thank you for any guidance.

Accepted Answer

Torsten
Torsten on 17 May 2024
Use
[output] = [method](@(AB) my_func(AB(1),AB(2)), [A B])
instead of
[output] = [method](@(A,B) my_func(A,B), [A B])

More Answers (0)

Categories

Find more on Get Started with Optimization Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!