macro to determine points of inflection

bisetti

Board Regular
Joined
Jun 16, 2003
Messages
216
is there a way to use vb to write a macro that will determine the points of inflection in a given set of data? for example to find all the peaks and vallies in a sine wave?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi bisetti,

The answer is yes, but how you would write this code depends on the functionality you want. For example

- do you want to interpolate between data points to estimate the true inflection points (which might be between data values), or do you just want the data values that are the local min and max values?

- what do you want the macro or function to do when it finds these points? Write them to a block of cells, or perhaps highlight them with colors in the original data set?

Damon
 
Upvote 0
Hi Damon,

I have lots of data and many files that I want to run this macro on. The data shows voltage and the overall shape is a sin wave, but its not completly smooth. I think by taking the absolute min and max, it might result in something that is not the true peak or valley i want. I can look at the data and very easily tell where the points are, but since they are not so smooth, i don't know if this will make it difficult for excel to determine. What I would like it to do after finding these points is to take the corresponding y values (which in this case y is time) and have the macro tell me the time between the two points by writing it in a cell.

Thanks for your help!
 
Upvote 0
Hi again bisetti,

Yes, if the data contain either noise or high-frequency components that you want to ignore (as you describe), then it is not just a straightforward matter of finding local max and min values. The algorithm would either have to do some local smoothing, filtering, or even curve fitting. If the signal is totally continuous with no transient part, I would recommend Fourier analysis which would give you the frequencies of the various harmonics, and from what you describe I believe you want the period (1/frequency) of the lowest harmonic (the fundamental frequency). Excel has a Fourier analysis tool (Excel mistakenly groups it in its Statistical tool set) that you could use for this.

But if the function is transient or has a significant transient component you should use smoothing, such as a sliding fit on a number of points that is small compared to the period of the fundamental frequency, looking for inflections in the fit function that are within the range of the sliding fit.

I hope this helps.

Damon
 
Upvote 0
Thanks for your help Damon.

I will check out the analysis tool. I think from what you describe it might be what I need.

Thanks again very much.
 
Upvote 0
Hi again bisetti,

You first have to have the Analysis Toolpack Add-ins loaded (Tools > Addins). Then you can access the Fourier Analysis Tool from Tools > Data Analysis > Fourier Analysis.
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,742
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top