Вопрос

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