+ Reply to Thread
Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    08-30-2009
    Location
    melbourne
    MS-Off Ver
    Excel 2003
    Posts
    9

    if there are two y-axis, how to set one of them to x-axis?

    Hi all,

    I have two big data, including 1) force vs. time and 2) strain vs. time. Im currently trying to plot force vs strain to find out the relationship between these factors. However, since the interval size of the time between 1) and 2) are not exactly identical, im not able to simply plot force vs strain even though the initial and the terminated time are the same. So im wondering if there is any way to do it.

    Thank you for your input and help in advance.

    Regards,
    Minki

  2. #2
    Registered User
    Join Date
    08-30-2009
    Location
    melbourne
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: if there are two y-axis, how to set one of them to x-axis?

    I've attached the data i would like to solve.

    Thanks
    Attached Files Attached Files

  3. #3
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,138

    Re: if there are two y-axis, how to set one of them to x-axis?

    The force column is all zeros.

    Were it not, you could interpolate time vs strain to get stress vs strain.
    Last edited by shg; 08-30-2009 at 08:54 PM.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    08-30-2009
    Location
    melbourne
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: if there are two y-axis, how to set one of them to x-axis?

    Hi Shg,

    Thank you for your input.

    Firstly, the force column is not all zeros.

    What do you mean by interpolating time vs strain to get stress vs strain?

    I mainly would like to get the relationship between force and strain, not stress vs Strain.

    Regards,
    Minki

  5. #5
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,138

    Re: if there are two y-axis, how to set one of them to x-axis?

    Firstly, the force column is not all zeros.
    Look at column B, labeled "Force"
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    08-30-2009
    Location
    melbourne
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: if there are two y-axis, how to set one of them to x-axis?

    From B80 to B197, they are non-zero values.

    Thanks

  7. #7
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,138

    Re: if there are two y-axis, how to set one of them to x-axis?

    Check the file you uploaded; it only has data to row 565, and it's all zero.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Registered User
    Join Date
    08-30-2009
    Location
    melbourne
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: if there are two y-axis, how to set one of them to x-axis?

    Hi Shg,

    Please see the attached image file from the data uploaded.

    Regards,
    Attached Images Attached Images

  9. #9
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,138

    Re: if there are two y-axis, how to set one of them to x-axis?

    Suggest you download the file you uploaded and look at it.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Forum Guru Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007
    Posts
    3,441

    Re: if there are two y-axis, how to set one of them to x-axis?

    In the attachement . .
    Autofiltering column-B for values greater than zero, shows B80:B197 to contains values greater than zero.

  11. #11
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,138

    Re: if there are two y-axis, how to set one of them to x-axis?

    Weird.

    Add this function to the workbook.
    Code:
    Private Sub dFrac(d As Double, r As Range, _
                      ByRef i As Long, ByRef dF As Double, _
                      iMatchType As Long)
        ' shg 1997-0606, 2009-0419
        '     2009-0604 added option for descending sort
    
        ' Returns an index to r in i and an interpolation fraction in dF
        ' r must be a 2+ element vector sorted a-/de-scending if iMatchType=1/-1
    
        If iMatchType = 1 And d <= r(1).Value2 Or _
           iMatchType = -1 And d >= r(1).Value2 Then
            i = 1
        Else
            i = WorksheetFunction.Match(d, r.Value2, iMatchType)
            If i = r.Count Then i = r.Count - 1
        End If
    
        dF = (d - r(i).Value2) / (r(i + 1).Value2 - r(i).Value2)
    End Sub
    
    Function LINTERP(x As Double, rX As Range, rY As Range) As Variant
        
        ' shg 1997-0606, 2009-0419
        '     2009-0604 added option for descending sort
    
        ' Linear interpolator / extrapolator
        ' Interpolates rX to return the value of y corresponding to the given x
    
        ' rX and rY must be equal-length vectors
        ' rX must be sorted ascending or decreasing
    
        Dim i       As Long     ' index to rY
        Dim dF      As Double   ' interpolation fraction
        Dim v       As Variant  ' for each/loop control variable
    
        For Each v In Array(rX, rY)
            If v.Areas.Count > 1 Then GoTo Oops
            If v.Rows.Count <> 1 And v.Columns.Count <> 1 Then GoTo Oops
            If WorksheetFunction.Count(v) <> v.Count Then GoTo Oops
        Next v
        If rX.Count < 2 Then GoTo Oops
        If rX.Count <> rY.Count Then GoTo Oops
    
        dFrac x, rX, i, dF, IIf(rX(rX.Count).Value2 > rX(1).Value2, 1, -1)
        LINTERP = rY(i).Value2 * (1 - dF) + rY(i + 1).Value2 * dF
        Exit Function
    
    Oops:
        LINTERP = CVErr(xlErrValue)
    End Function
    In C2 and copy down,

    =LINTERP(A3,$D$3:$D$337,$E$3:$E$337)

    ... then plot columns B & C
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  12. #12
    Registered User
    Join Date
    08-30-2009
    Location
    melbourne
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: if there are two y-axis, how to set one of them to x-axis?

    Hi Shg,

    It works very well..

    Thank you very much..

    Regards,
    Minki

Thread Information

Users Browsing this Thread

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

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.2.0