Variable optimization to minimize cost in array

1 view (last 30 days)
Hi eveyone,
I basically have a "fitting" problem but I can't solve it:
Given a bunch of variables x0, x1, x2, x3... xn, I create an array X=function(x0,x1,x2,x3). Then I compare X to an exisiting vector Y. Now, a function should iterate and optimize x0...xn in order to minimize the cost function Y-X.
Note that X and Y cannot be expressed as symbolic functions. Is there a build in function that can help me do this?

Answers (1)

Alan Weiss
Alan Weiss on 7 Dec 2020
Well, you probably want to minimize the cost function sum((Y - X).^2) or some such thing. Yes, there are many functions for doing this, dependng on exactly what your function is. if it is a smooth function, then this sounds like a job for lsqnonlin or lsqcurvefit from Optimization Toolbox™. If it is a linear frunction, then the basic MATLAB \ function works wonders.
Alan Weiss
MATLAB mathematical toolbox documentation

Categories

Find more on Mathematics and Optimization 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!