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:
Find local and global extremes from set of points

Subject: Find local and global extremes from set of points

From: Pivo

Date: 10 Aug, 2009 21:47:19

Message: 1 of 7

Hey!

For testing purposes I have been working with function f(x) = x^3 - 2*x^2 + 1 and successfully found the solution.

But...

Here is my problem.
I am reading a data (temperature) from external device (through serial port). Reading interval is 500ms (0.5s). After 1000 samples, I need to find the local and global extremes of those data.

I don't know how to start from here. I don't know what the function looks like.
Since I know the points, I could do Lagrange interpolation (this is the only one I know from school), but I would rather ask for your opinion...

I don't ask for solution, although I would appreciate it.
I am only asking, what would be the right approach (links, keywords,...)

Thanks

Subject: Find local and global extremes from set of points

From: TideMan

Date: 10 Aug, 2009 22:45:44

Message: 2 of 7

On Aug 11, 9:47 am, "Pivo " <pivo_pijem.remove.t...@hotmail.com>
wrote:
> Hey!
>
> For testing purposes I have been working with function f(x) = x^3 - 2*x^2 + 1 and successfully found the solution.
>
> But...
>
> Here is my problem.
> I am reading a data (temperature) from external device (through serial port). Reading interval is 500ms (0.5s). After 1000 samples, I need to find the local and global extremes of those data.
>
> I don't know how to start from here. I don't know what the function looks like.
> Since I know the points, I could do Lagrange interpolation (this is the only one I know from school), but I would rather ask for your opinion...
>
> I don't ask for solution, although I would appreciate it.
> I am only asking, what would be the right approach (links, keywords,...)
>
> Thanks

Define "local" vs "global" extremes.
But in any case what you need is:
help max
help min

Subject: Find local and global extremes from set of points

From: Thomas Clark

Date: 10 Aug, 2009 23:00:22

Message: 3 of 7

Min and max functions will only give you a global max/min, which will be subject to experimental errors and spikes.

plot your data as a time seires. Is it smooth (i.e. you can clearly see where your local minima should be), or is it a little spiky?

If spiky, I'd suggest filtering it (either low-pass filtering, which is probably easier, or check out Michael Kleder's tutorial on the Kalman Filter).

Next, type in search terms like 'minimise' 'local minima' and global minima... there are hundreds of pieces of code floating aroud, many on the File Exchange, which find local minima of functions. Root through them, you'll probably get a better idea of what you need as you go.

Other than that, I'd probably just quickly write a gradient-based minimiser (or there must be one somewhere on the FEx) and start it off at a number of different points along the line to get all the local minima.

Good luck!



"Pivo " <pivo_pijem.remove.this@hotmail.com> wrote in message <h5q4h7$pce$1@fred.mathworks.com>...
> Hey!
>
> For testing purposes I have been working with function f(x) = x^3 - 2*x^2 + 1 and successfully found the solution.
>
> But...
>
> Here is my problem.
> I am reading a data (temperature) from external device (through serial port). Reading interval is 500ms (0.5s). After 1000 samples, I need to find the local and global extremes of those data.
>
> I don't know how to start from here. I don't know what the function looks like.
> Since I know the points, I could do Lagrange interpolation (this is the only one I know from school), but I would rather ask for your opinion...
>
> I don't ask for solution, although I would appreciate it.
> I am only asking, what would be the right approach (links, keywords,...)
>
> Thanks

Subject: Find local and global extremes from set of points

From: ImageAnalyst

Date: 11 Aug, 2009 00:53:27

Message: 4 of 7

For local extremes, he could try the imextendedmin() and imextendedmax
() functions in the image processing toolbox, or the findpeaks()
function in the signal processing toolbox.

I have no idea why you think you'd want to do Lagrange interpolation.
You have the data so just use it. Why make up wildly oscillating data
in between your data points?

Subject: Find local and global extremes from set of points

From: someone

Date: 11 Aug, 2009 03:48:04

Message: 5 of 7

"Pivo " <pivo_pijem.remove.this@hotmail.com> wrote in message <h5q4h7$pce$1@fred.mathworks.com>...
> Hey!
>
> For testing purposes I have been working with function f(x) = x^3 - 2*x^2 + 1 and successfully found the solution.
>
> But...
>
> Here is my problem.
> I am reading a data (temperature) from external device (through serial port). Reading interval is 500ms (0.5s). After 1000 samples, I need to find the local and global extremes of those data.
>
> I don't know how to start from here. I don't know what the function looks like.
> Since I know the points, I could do Lagrange interpolation (this is the only one I know from school), but I would rather ask for your opinion...
>
> I don't ask for solution, although I would appreciate it.
> I am only asking, what would be the right approach (links, keywords,...)
>
> Thanks

You might download and try "extrema" from the MATLAB FEX at:

http://www.mathworks.com/matlabcentral/fileexchange/12275

Subject: Find local and global extremes from set of points

From: Pivo

Date: 14 Aug, 2009 09:56:03

Message: 6 of 7

This are the real world examples:

http://a.imagehost.org/0424/pic1.png
http://a.imagehost.org/0979/pic2.png

(let me remind you: all I have is array of data)

Min, Max will not work in this case

Subject: Find local and global extremes from set of points

From: Pivo

Date: 14 Aug, 2009 10:04:04

Message: 7 of 7

Local extrema can be found by Fermat's theorem, which states that they must occur at critical points. One can distinguish whether a critical point is a local maximum or local minimum by using the first derivative test or second derivative test.
(source: http://en.wikipedia.org/wiki/Maxima_and_minima#Finding_maxima_and_minima
)
Yes, but how to find 1st derivative of set of data! That is why I was thinking of interpolation.

Tags for 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