Variable optimization to minimize cost in array

조회 수: 6 (최근 30일)
MatteoC
MatteoC 2020년 12월 7일
답변: Alan Weiss 2020년 12월 7일
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에서 Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by