문제

I'm aware of the fminsearch function, but it only seems to be able to solve for one variable.

If my function looks like f(x,y,z) and I want to find the values of x,y,z that gives the lowest result, how would I do this in MatLab? The complexity of f would make it unreasonably difficult to calculate the partial derivatives.

Any help would be appreciated, thanks!

도움이 되었습니까?

해결책

fminsearch is multivariable, for example:

a = fminsearch(@(x)((x(1)-1)^2+(x(2)-2)^2), [0,0]);

the parameter passed to the objective function can be a vector, just be sure to specify the x0 parameter (the second parameter in fminsearch) to the right size.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top