Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interpolating

Status
Not open for further replies.

rm2

Mechanical
Jun 7, 2005
41
0
0
MX
Hello,

I have to vectors (flow and pressure).
I am scatter plotting them (flow vs pressure). I did it before, I do not recall how I interpolated around for a certain value of let say pressure and have the flow value on that specific point...
hope anyone can help me, thanks


 
Replies continue below

Recommended for you

Excel has functions for curve fitting, like linest and logest, from which you get the parameters for doing the interpolations.

TTFN

FAQ731-376
 
I'm sure there are some built in excel functions that's do what you want.

Personally rather then worrying about that syntax I would rather just write the formula. Then you can do the same thing in Matlab or Maple or whatever. Math works in any language.

Step 1: What is the slope of a line passing through two points: (X1,Y1) and (X2,Y2).
Think about it before you read the answer.
Answer: slope = (Y2-Y1)/(X2-X1)

Step 2: How do I use that slop to find the value of Y at some arbitrary X in the interval (X1,YX)?
Think about it before you read the answer.
Answer:
Y = Y1 + slope * (X-X1)

Sorry I am not trying to be a jerk. It is something you should spend time understanding (rather than memorizing) imo.


=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
obvious typo correction in bold:
Step 2: How do I use that slope to find the value of Y at some arbitrary X in the interval (X1,X2)?

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
I apologize if I have underestimated your problem. Maybe you want a general formula to work with two columns of X, Y data. Then you need to use some lookups if you are going to build the arguments for the interpolation formula if you are going to build it yourself.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
Here is a vba function to return the interpolation from a range of X's and Y's:
Code:
Function InterpL(LookupValue, KnownXs, KnownYs)
Dim pointer As Integer
Dim XO As Double, YO As Double, X1 As Double, Y1 As Double
pointer = Application.Match(LookupValue, KnownXs, 1)

XO = KnownXs(pointer)
YO = KnownYs(pointer)
X1 = KnownXs(pointer + 1)
Y1 = KnownYs(pointer + 1)
InterpL = YO + (LookupValue - XO) * (Y1 - YO) / (X1 - XO)
End Function


=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
And yes this is linear interpolation. For a higher order interpolation you need a spline technique. Let us know if you are interested in that.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
Hmmm. I thought I was in the excel forum - hence the vba function. IRStuff sent me off track (or maybe I just wasn't paying attention).

Use interp1 for simple interpolation like you are talking about.

Interp2 is for 2-d interpolation.

There is a lot of help in the help

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
Status
Not open for further replies.
Back
Top