Attribute VB_Name = "Module1"
Sub Plot_IMU_Data()
Attribute Plot_IMU_Data.VB_ProcData.VB_Invoke_Func = " \n14"
'
' Plot_IMU_Data ¸ÅÅ©·Î
'
'
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Find the index of a maximum value.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Dim MaxIndex As Integer
    Dim MinIndex As Integer
    
    MaxIndex = Application.Match(Application.Max(Range("I:I")), Range("I:I"), 0)
    MinIndex = Application.Match(Application.Min(Range("I:I")), Range("I:I"), 0)
    
    Range("X3").Value = "Value"
    Range("Y3").Value = "Index"
    
    Range("W4").Value = "Max"
    Range("X4").Value = CStr(Application.Max(Range("I:I")))
    Range("Y4").Value = CStr(MaxIndex)
    
    Range("W5").Value = "Min"
    Range("X5").Value = CStr(Application.Min(Range("I:I")))
    Range("Y5").Value = CStr(MinIndex)
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Draw a graph of ACC RMS.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ActiveSheet.Shapes.AddChart2(233, xlLine, 0, 50).Select

    rr = "H" + CStr(MaxIndex - 100) + ":H" + CStr(MaxIndex + 50) + ", I" + CStr(MaxIndex - 100) + ":I" + CStr(MaxIndex + 50)
    
    ActiveChart.SetSourceData Source:=Range(rr)
    
    ActiveChart.ChartTitle.Text = "ACC"
    
    ActiveChart.FullSeriesCollection(1).Name = "=""LPF_ACC"""
    ActiveChart.FullSeriesCollection(2).Name = "=""RAW_ACC"""
    
    ActiveChart.SetElement (msoElementLegendBottom)
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Draw a graph of GYRO RMS.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ActiveSheet.Shapes.AddChart2(233, xlLine, 400, 50).Select

    rr = "J" + CStr(MaxIndex - 100) + ":J" + CStr(MaxIndex + 50) + ", K" + CStr(MaxIndex - 100) + ":K" + CStr(MaxIndex + 50)
    
    ActiveChart.SetSourceData Source:=Range(rr)
    
    ActiveChart.ChartTitle.Text = "GYRO"
    
    ActiveChart.FullSeriesCollection(1).Name = "=""LPF_GYRO"""
    ActiveChart.FullSeriesCollection(2).Name = "=""RAW_GYRO"""
    
    ActiveChart.SetElement (msoElementLegendBottom)
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Draw a graph of Roll & Pitch.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ActiveSheet.Shapes.AddChart2(233, xlLine, 800, 50).Select
    
    rr = "M" + CStr(MaxIndex - 100) + ":M" + CStr(MaxIndex + 50) + ", N" + CStr(MaxIndex - 100) + ":N" + CStr(MaxIndex + 50)
    
    ActiveChart.SetSourceData Source:=Range(rr)
    
    ActiveChart.ChartTitle.Text = "Roll & Pitch"
    
    ActiveChart.FullSeriesCollection(1).Name = "=""Roll"""
    ActiveChart.FullSeriesCollection(2).Name = "=""Pitch"""
    
    ActiveChart.SetElement (msoElementLegendBottom)
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Draw a graph of ACC.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ActiveSheet.Shapes.AddChart2(233, xlLine, 0, 300).Select
    
    rr = "B" + CStr(MaxIndex - 100) + ":B" + CStr(MaxIndex + 50) + ", C" + CStr(MaxIndex - 100) + ":C" + CStr(MaxIndex + 50) + ", D" + CStr(MaxIndex - 100) + ":D" + CStr(MaxIndex + 50)
    
    ActiveChart.SetSourceData Source:=Range(rr)
    
    ActiveChart.ChartTitle.Text = "ACC"
    
    ActiveChart.FullSeriesCollection(1).Name = "=""AX"""
    ActiveChart.FullSeriesCollection(2).Name = "=""AY"""
    ActiveChart.FullSeriesCollection(3).Name = "=""AZ"""
    
    ActiveChart.SetElement (msoElementLegendBottom)
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Draw a graph of GYRO.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ActiveSheet.Shapes.AddChart2(233, xlLine, 400, 300).Select
    
    rr = "E" + CStr(MaxIndex - 100) + ":E" + CStr(MaxIndex + 50) + ", F" + CStr(MaxIndex - 100) + ":F" + CStr(MaxIndex + 50) + ", G" + CStr(MaxIndex - 100) + ":G" + CStr(MaxIndex + 50)
    
    ActiveChart.SetSourceData Source:=Range(rr)
    
    ActiveChart.ChartTitle.Text = "GYRO"
    
    ActiveChart.FullSeriesCollection(1).Name = "=""GX"""
    ActiveChart.FullSeriesCollection(2).Name = "=""GY"""
    ActiveChart.FullSeriesCollection(3).Name = "=""GZ"""
    
    ActiveChart.SetElement (msoElementLegendBottom)
End Sub
