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?
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!