How can I find the changing maximum of a function as another parameter changes

1 view (last 30 days)
For example if I have a function:
y=-Ax^2+Bx+C-Dcos(Ax)
where A B C and D are constants and x is the independent variable
I would like to find the maximum of the function at different values of A

Accepted Answer

Udit Gupta
Udit Gupta on 23 Jun 2015
The fact that you require to find something with different values of A implies that A can no longer be treated as a constant. So in effect this is a two dimensional function
y(A,x) =-Ax^2+Bx+C-Dcos(Ax)
To find the maximum you can use various methods -
1.you can wither use multi-dimensional derivatives to find maxima, minima and saddle points (see a calculus textbook)
2. In matlab use meshgrid to continuously vary A and x and plot a surface plot to find the maximum.
3. Realize that y is a sum of a quadratic function and a periodic cosine. The extrima of a quadratic function is the vertex (can be either maxima or minima depending on sign of A) and that the periodic function varies between +/-D. So analyzing it becomes not too difficult.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!