cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

How the looking up works in this mathCAD example

ptc-4323006
1-Visitor

How the looking up works in this mathCAD example

Hi, there:

I am trying to using MathCAD to interpolate a value from a table in Excel.

I found the following post that is very similar to what I want. http://communities.ptc.com/message/29193

The last post got a MathCAD example that can reach this goal. (attached)

However, I cannot figure out how this been done?

How the interpolated happens? I didn't see any function to do this.

May you please give me some help for this?

Thanks,

ACCEPTED SOLUTION

Accepted Solutions

I tried to explain it to Mike, see my answer to his post.

Attached is the completed file, able to interpolate each column.

This could be made more streamlined with a little thought and effort.

View solution in original post

44 REPLIES 44

I think there is a locked area that need password on that sheet.

Where did you find in this worksheet a locked area?

The 1st lock area is right under the first table.

The 2nd lock area is under the enter value S and D.

Hello!

In Mathcad can be used as a linear interpolation (built-in function "linterp") and also cubic spline interpolation (built-in functions: "interp"; "cspline"; "pspline"; "lspline"). Please see the attachment with a simple example of interpolation in Mathcad.

P.S. Which version of Mathcad are you running (files attached for versions of MC12 and 15)?

My version is MC15.

Thanks fo the examples. I am trying to do a simply linear interpolation. I will attach my worksheet as Mike mentioned soon.

Thanks,

As Vladimir suggests there are many ways this can be achieved. To get the best results I would suggest you upload the data you are trying to interpolate between.

Mike

Here is a function which I wrote.

Mike

Mike,

Your check for values larger than max(x) does not work.

Lev

Fred_Kohlhepp
23-Emerald I
(To:Lev)

lev zilberman wrote:

Mike,

Your check for values larger than max(x) does not work.

Lev

Yes, it does; it returns a statement that you are outside the range of the table.

Trying to g outside your range of data in NOT interpolation, it's extrapolation, and it's dangerous without understanding the problem.

Mike's program provides a warning that you are walking in quicksand!

Trying to g outside your range of data in NOT interpolation, it's extrapolation, and it's dangerous without understanding the problem.

Mike's program provides a warning that you are walking in quicksand!

I like it.

Mike

Shouldn't I get a warning for n=100?

MikeArmstrong
12-Amethyst
(To:Lev)

I do.

Clipboard01.jpg

Mike

I was commenting on worksheet you posed on Nov 10, 2011 4:33 AM. I posted my copy of the worksheet without renaming it (my mistake).

MikeArmstrong
12-Amethyst
(To:Lev)

I didn't post a worksheet at that time, unless I did when was asleep

Mike

I see now, there was a slight error in my Boolean commands.

Good spot

Mike

MikeArmstrong
12-Amethyst
(To:Lev)

Yes it does.

Mike

Please find my attached function with the update.

Mike

The sheet you found is a bad example of mathcad interpolation; most of the useful stuff is in the closed and locked area.

Interpolation in mathcad is possible a variety of ways, Read the help files for "interp" and "linterp"

"linterp" will do a straight-line interpolation between successive points and is very robust and easy if your points are closely spaced.

"interp" does a variety of curve fits to a data set.

Thanks for all the replies. I am still new to mathCAD programming functions, even though I have been using MathCAD for 5-6 years, I only use the very basic functions for my structural calculation.

Please see the attached worksheet for the work that I am trying to work on.

What I need is something simliar to the original post I quoted.

The table is from a design code, with a give angle (22 degree), I need to interpolate all the numbers of the line of "20 degree" and "30-45 degree".

Thanks for all the help!

Now you have a very tricky problem because of the way Mathcad uses the Interpolation functions. It requires the data to be in ascending order.

Mike

Thanks, Mike.

If that is the case, I guess the alternative for my worksheet is to do the interpolation in Excel, which will give me a table of the slope degree from 0-90. Then I use the table lookup function in MatchCAD. The only extra step is I have to ask people to choose the angle, which can be done by the listbox function you taught me yesterday.

That sounds a little taxing. Can you just confirm that you are trying to interpolate between a single value from the column "20 degree" and "30-45 degree"?

Or am i missing something?

Mike

Have a look at the attached, I think this is what your after.

Clipboard01.jpg

This could be made fully automated, but I'll wait and see if this is correct

Mike

wayne
12-Amethyst
(To:ptc-4323006)

Since the tables are fixed in the code, and not very complicated, I think you'd be better off just writing the functions diectly.

Then you do not need to import tables.

I'm liking that Wayne, but I'm sure he want the results running the other way down the table. Unless I'm mistaken.

Mike

Hi Mike,

Each column of the table refers to a different area of roof; corner, along edge, along ridge, etc. You can't interpolate between roof areas.

Ok Wayne, did you see my example above?

The way Jiabao sent his definitions up on the left hand side of the worksheet indicated he wanted to interpolate 10 times across the matrix, between the rows dictated by the angle, which I have done. Otherwise I cannot see why he has named the variables to coincide with the top row of the matrix.

Mike

Mike,

The variable is the roof angle.

He wanted to interpolate within each column with respect to the roof angle.
He just needs to write a short function for each columns.

Sorry for the confusion, it's getting late here and I've had a long day

These are the values I interpolated between, which as you said is incorrect.

Clipboard01.jpg

Mike

Message was edited by: Mike Armstrong - Just thought on - What does the variables across the top mean then, running from 1 - 4E?

Announcements

Top Tags