Gradient of a self defined function.

1 visualización (últimos 30 días)
123123123
123123123 el 27 de En. de 2018
Respondida: Arun Mathamkode el 30 de En. de 2018
Hi there, I created a function similar to this one:
function [scalar] = myfunc(vector)
% stuff happening here
end
So it takes a vector and returns a scalar. I am interested in this: if i start with any given vector, how should I adjust it so that the scalar of the function maximizes. So I want the gradient of my function basically. How do I get it?
If I try:
a = myfunc(b);
gradient(a)
I get an error. How am I supposed to get the gradient? Any help is appreciated!

Respuestas (1)

Arun Mathamkode
Arun Mathamkode el 30 de En. de 2018
It looks like you are passing a vector to myfunc and it returns a scalar. Now you want to adjust the vector such that the scalar is maximum.
I think rather than looking for finding the gradient you can use the fmincon function. First, you need to convert the maximization problem into a minimization problem as described here. Then you can pass the function handle of the myfunc to the fmincon function along with an initial guess of the vector b.

Categorías

Más información sobre Matched Filter and Ambiguity Function en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by