Variable optimization to minimize cost in array

2 次查看(过去 30 天)
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?

回答(1 个)

Alan Weiss
Alan Weiss 2020-12-7
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

类别

Help CenterFile Exchange 中查找有关 Mathematics and Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by