Variable optimization to minimize cost in array

2 visualizaciones (últimos 30 días)
MatteoC
MatteoC el 7 de Dic. de 2020
Respondida: Alan Weiss el 7 de Dic. de 2020
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?

Respuestas (1)

Alan Weiss
Alan Weiss el 7 de Dic. de 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

Categorías

Más información sobre Mathematics and Optimization en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by