×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Interpolating

## Interpolating

(OP)
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

### RE: Interpolating

Have you tried linear interpolation?

=====================================
Eng-tips forums: The best place on the web for engineering discussions.

### RE: Interpolating

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

### RE: Interpolating

(OP)
is it interp2?
I will try tomorrow morning

### RE: Interpolating

Do you want an interpolation or a best fit line?

use "polyfit" for the latter

M

--
Dr Michael F Platten

(OP)
Interpolation

### RE: Interpolating

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

Step 2: How do I use that slop to find the value of Y at some arbitrary X in the interval (X1,YX)?
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.

### RE: Interpolating

obvious typo correction in bold:

#### Quote:

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.

### RE: Interpolating

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.

### RE: Interpolating

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.

### RE: Interpolating

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.

### RE: Interpolating

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.

### RE: Interpolating

If you are using interp1, be sure that your independent axis (you haven't told us whether it's pressure or flow) is monotonic.

- Steve

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!