Results 1 to 2 of 2

Extracting peaks and trough from Noisy data

Threaded View

  1. #1
    Registered User
    Join Date
    01-06-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    1

    Extracting peaks and trough from Noisy data

    Hi All
    I am new to this forum. Thanks for having me as your member
    I am testing some product and getting large amount of data from the machine.
    I want to Automate some of the boring data analysis, peak detection, trough detection, if possible the point of change ( this is very difficult because of the data is being noisy and not regular.)
    I have adopted this vba code, but this is is very slow. Its taking half an hour to run. Could an experienced user suggest a better way to detect peak and output the x and y value?

    Sub GetMax()
        Dim chr As ChartObject
        Dim chrSeries As Series
        Dim lngrow, sum As Long
        Dim Max As Long
        Application.ScreenUpdating = False
        Max = 0
        sum = 0
        On Error Resume Next
        
        Set chr = ActiveSheet.ChartObjects(1)
        Set chrSeries = chr.Chart.SeriesCollection(1)
        
        On Error GoTo 0
        
        If chrSeries Is Nothing Then Exit Sub
        
        For lngrow = 101 To UBound(chrSeries.Values) - 100
            
            For i = 1 To 100
            
                sum = sum + chrSeries.Values(lngrow + i) + chrSeries.Values(lngrow - i)
                
                If chrSeries.Values(lngrow) > chrSeries.Values(lngrow - i) Then
                    If chrSeries.Values(lngrow) > chrSeries.Values(lngrow + i) Then
                        temp = chrSeries.Values(lngrow)
                        Max = WorksheetFunction.Max(temp, Max)
                        
                    End If
                End If
            Next i
            NewMax = Max - (sum + chrSeries.Values(lngrow)) / 100
                If NewMax > 0.5 Then
                        chrSeries.Points(lngrow).ApplyDataLabels
                        With chrSeries.Points(lngrow).DataLabel
                            .Position = xlLabelPositionCenter
                            .Border.Color = 1
                        End With
                        
                  End If
        Next
        
        Application.ScreenUpdating = True
    End Sub

    Thanks in advance for your help
    Attached Files Attached Files
    Last edited by alansidman; 01-09-2014 at 01:04 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Skip periodic and noisy data point 4000 times
    By baz0110 in forum Excel General
    Replies: 0
    Last Post: 05-17-2012, 02:05 AM
  2. Peak picking noisy data Excel 2008 mac
    By theoneness in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 11-22-2009, 02:59 PM
  3. Replies: 1
    Last Post: 11-02-2009, 09:00 AM
  4. Identifying Peaks in Data
    By SportsScientist in forum Excel General
    Replies: 11
    Last Post: 05-06-2009, 07:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1