Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
function in matlab to find local maxima and minima

Subject: function in matlab to find local maxima and minima

From: Johny Salvo

Date: 13 Dec, 2011 20:56:09

Message: 1 of 3

Hi, I just wonder if there is a function in matlab to find local maxima and minima of a function.

For the minima , I use fminbnd, for maxia, I see that there is no built in function.

I am looking to local maxima for the function y=x2+3-[3/(x3+1)] between the interval
-5 and 5.

I tried to graph it but as you can alo see, it is a little bit complex graphics and I could not quess it from the plotted graph.

I tried to use fzero, but with fzero I get more small value than minima point that I get with fminbnd. Anyone can help ? How can I find it ? I need an easy way please.

Subject: function in matlab to find local maxima and minima

From: Matt J

Date: 13 Dec, 2011 21:04:09

Message: 2 of 3

"Johny Salvo" <johnysalvo@yahoo.com> wrote in message <jc8e58$bg5$1@newscl01ah.mathworks.com>...
> Hi, I just wonder if there is a function in matlab to find local maxima and minima of a function.
>
> For the minima , I use fminbnd, for maxia, I see that there is no built in function.
>
> I am looking to local maxima for the function y=x2+3-[3/(x3+1)] between the interval
> -5 and 5.
==================

To find maxima, use FMINBND to find the minima of -y.

Subject: function in matlab to find local maxima and minima

From: Roger Stafford

Date: 13 Dec, 2011 23:42:09

Message: 3 of 3

"Johny Salvo" <johnysalvo@yahoo.com> wrote in message <jc8e58$bg5$1@newscl01ah.mathworks.com>...
> Hi, I just wonder if there is a function in matlab to find local maxima and minima of a function.
> .......
> I am looking to local maxima for the function y=x2+3-[3/(x3+1)] between the - - - - - - - - -
  For finding local maxima and minima you shouldn't overlook methods of simple calculus. A function such as yours with a continuous derivative (except at x = -1) will have a zero derivative at all such local maxima and minima points. In your case you can use matlab's symbolic 'diff' and 'roots' to find these points. The sign of the second derivative there will distinguish between the two possibilities.

  (I'm assuming you meant y=x^2+3-3/(x^3+1) here.)

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us