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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

New lookup function

MikeArmstrong
12-Amethyst

New lookup function

I am trying to write a function which is similar to Mathcad’s built in lookup functions. I have managed to write a basic version which will accept a variable ‘n’ as a decimal (the function rounds the variable to the nearest whole number) and return the corresponding values from the Matrix ‘cc’ using the predefined function subvector.

The reason for the function is to allow the user to extract the required values from the table to allow for interpolation.

Any criticism or improvements are welcome.

Mike

29 REPLIES 29

I have improved my function by adding additional arguments to it.

At the moment the function can only take c1 as the first column of the Matrix cc due to the rounding, because the first column of Matrix cc is numbered 1..9 when a decimal is inserted as argument n the function can either round up or down to the nearest whole number.

But this isn't the case if say, n is changed to 88 and c1 changed to matrix column 1 for example.

This is work in progress, just thought it might help other collabs with the development of the sheet.

Mike

Mike,

You are just talking to yourself !

None of the two work sheets download !!!

2 days ago, James had 5 work sheets about optics,

only 2 did download .

What's wrong ? Don't know

IRstuff
12-Amethyst
(To:jeanGiraud)

There's nothing wrong. All files are accessible and downloadable

>There's nothing wrong. All files are accessible and downloadable< [Eden].

---------------------------

I'm not so lucky. 5 files from the same poster, at the same time and 3 out of 5 that don't download ... my conclusion is that the problem is not on my side .

Your observation is certainly very useful for diagnostic.

Eden Mei wrote:

There's nothing wrong. All files are accessible and downloadable

If it works for you Eden, it should work for all of us. Interesting your observation. Richard said no problem , then some problem ... Philip and me have problems . I say Philip from what he let understand. Mona is surely reading all these complaints.

jean Giraud wrote:

Mike,

You are just talking to yourself !

None of the two work sheets download !!!

2 days ago, James had 5 work sheets about optics,

only 2 did download .

What's wrong ? Don't know

Jean,

I seem to be able to download and open the zip files.

Mike

Some comments in the attached.

Richard Jackson wrote:

Some comments in the attached.

Richard,

Cheers for looking at the sheet and your comments.

I have only just returned from site and will look at your example closer tomorrow morning. I have a modified version of the function which I wrote today, will post tomorrow -(Spent most of the day onit instead of doing what I get paid for)

Mike

Here is my finished function. (It seems to work!!!!!!)

Obviously with the information you and Jean provided I might not even use this function now, just thought it was worth trying to complete before disregarding.

Cheers

Mike

1. None of your work sheets download

2. Richard work sheet does not download either ,

but it opens and does not resave *.zip because Mathcad does not have *.zip saving option... only *.mcd. That's what I was saying about a "transit filing system" consequently slowing collaboration and making it botherish.

............................................

"New lookup" ? You seem to linearly interpolate for a column or eventually two or more columns. Your setup does not work from the start as you augment without considering the length of the column ! That's one point. If you want to linearly interpolate " a " column, the reference can be anything, but not completely anything, only anything that represents the range of the X variate ! We agree on that . You can simply create the "fake X variate" as one of the vector for the "linterp(vx,vy,t). The attached work sheet contains 3 modules:

1. Functional interpolator

2. Abaque interpolant linéaire

3. Abaque interpolant cubique.

1/. Speaks by itself.

2/. Borrows the Mathcad construct for the "Nearest next", you can modify to include 3 or 4 points around the 't' . Per say , 2 X's below 't' and one up ... 2 below, 2 up or 1 below 't' and 2 up. That way of interpolating is "balistic".

3/. Is basically the same as 2/. but cubique on Hermite cubique spline.

Question ?

Are you looking for a tool that would interpolate [let's say linearly] through a range or all columns of a data set and to report all corresponding 't' and the nearest reference points of each column ?

Jean

jean Giraud wrote:

1. None of your work sheets download

2. Richard work sheet does not download either ,

but it opens and does not resave *.zip because Mathcad does not have *.zip saving option... only *.mcd. That's what I was saying about a "transit filing system" consequently slowing collaboration and making it botherish.

As I have said before I cannot understand why the *.mcd files are being uploaded as *.zip files.

1. Functional interpolator


Question ?

Are you looking for a tool that would interpolate [let's say linearly] through a range or all columns of a data set and to report all corresponding 't' and the nearest reference points of each column ?

Jean

Your Functional interpolator function looks the business and seems at first glance close to what Richard has posted. I am looking for a tool which will linearly interpolate between columns of data.

For example

Sometimes in engineering when the operational temperature of steel is taken into account the yield strength of the material deceases. Therefore the reduced yield strength value would have to be found. Usually the table would show increaments of ....

  • 10degree - 207GPa
  • 20degree - 200GPa....... and so on.

I want the user to be able to choose what two coloums they want linearly interpolated between.

Hope this makes sense.

Mike

There is nothing to understand about *.zip , simply that the effect on Mathcad work sheet has 0 or near 0 reduction effect in file size. The PTC community data base may be coded with greatest effectiveness, that's the sole apparent reason. The real problem is that PTC "zipper" corrupts something for some collabs at the time they upload to the data base, it might not affect some system as reported by Richard & Eden, but mine finds it zombie. If you have a single column of °C vs several columns, just plug the column 'c' you want, like demonstrated. If you have paired X's Y's, just plug the corresponding pair. If you want to populate and interpolate, then a very simple job to include the interpolator in a discretizing loop.

Jean

>I want the user to be able to choose what two columns they want linearly interpolated between.< [Mike]
______________________________

The matter is then to apply Valery rectangular spline [if your matrix would be square it would be the "Square Diagonal Interpolant", but the rectangular does it too]. The X column is your choice, as long as it makes sense. The heading column will then be integers representing the column number and it will read between any two columns for the proportional part between the two adjacent columns.
Example: for X = 25 ½ way between 20...30
you want to read between column 2 & 3 at a proportional part 0.123456789
it will then be: Spline(M,25,2.123456789)
between columns 4 & 5 at a proportional part 0.987654321
it will then be : Spline(M,25, 4.987654321
.......................... and so on .........................
Spline(M,39.71,6.314) will interpolate between columns 6 & 7 at the proportional part 0.314between these two columns and @ proportional part 0.971 between rows valued 30 & 40.

Never mind linear, as long as the data table will have > 3 rows 3 cols.
You can do linterp as well, but the spline is more versatile (use lspline).

Jean

jean Giraud wrote:

>I want the user to be able to choose what two columns they want linearly interpolated between.< [Mike]
______________________________

The matter is then to apply Valery rectangular spline [if your matrix would be square it would be the "Square Diagonal Interpolant", but the rectangular does it too]. The X column is your choice, as long as it makes sense. The heading column will then be integers representing the column number and it will read between any two columns for the proportional part between the two adjacent columns.
Example: for X = 25 ½ way between 20...30
you want to read between column 2 & 3 at a proportional part 0.123456789
it will then be: Spline(M,25,2.123456789)
between columns 4 & 5 at a proportional part 0.987654321
it will then be : Spline(M,25, 4.987654321
.......................... and so on .........................
Spline(M,39.71,6.314) will interpolate between columns 6 & 7 at the proportional part 0.314between these two columns and @ proportional part 0.971 between rows valued 30 & 40.

Never mind linear, as long as the data table will have > 3 rows 3 cols.
You can do linterp as well, but the spline is more versatile (use lspline).

Jean

Jean,

I have just found the worksheet you where referring to which was produced by Valery. - (I moan enough about this site, but I must give credit to PTC for the search feature compared to the one in the collab, must better IMO),

This function seems to be the solution which I was after. It removes the need of the user choosing which column he wants interpolated. The only thing which is a slight disadvantage to the functions posted by meself and Richard is the user will still have to manually count which value of x/y to input.

Mike

To close this thread out and to help with documentation I have placed all suggestions from the above posts into one sheet.

Have a look at the worksheet might be worth keeping.

Cheers

Mike

Sorry Mike,

Your work sheet does not download.

PTC community must be fixed !

Jean

jean Giraud wrote:

Sorry Mike,

Your work sheet does not download.

PTC community must be fixed !

Jean

Jean,

I can't understand why you can't download my worksheets.

Has anybody else had any problems specifically with my uploaded sheets?

Mike

Jean,

I can't understand why you can't download my worksheets.

Has anybody else had any problems specifically with my uploaded sheets?

Mike

I think other people are having problems, but not to the extent Jean is. Perhaps it has something to do with connection speed?

Jean: do you have a slow internet connection?

Richard Jackson wrote:

Jean,

I can't understand why you can't download my worksheets.

Has anybody else had any problems specifically with my uploaded sheets?

Mike

I think other people are having problems, but not to the extent Jean is. Perhaps it has something to do with connection speed?

Jean: do you have a slow internet connection?

Richard,

The connection speed which we achieve onsite is poor to say the least. It can take upto a minute to open the reply page, so surly it can't be down to Internet speed.

Mike

The connection speed which we achieve onsite is poor to say the least. It can take upto a minute to open the reply page, so surly it can't be down to Internet speed.

Oh well. Another great theory goes down in flames!

LouP
12-Amethyst
(To:MikeArmstrong)

Just when Mike thought "To close this thread out...," I decided to check my posting skills on the new forum.

The attached has a modified column interpolator (the LP version), but does not require the input column c1 to be increasing. Unless I'm missing something in the intended structure, I don't see any need to do any element/submatrix extractions.

Lou

MikeArmstrong
12-Amethyst
(To:LouP)

Louis Poulo wrote:

Just when Mike thought "To close this thread out...," I decided to check my posting skills on the new forum.

The attached has a modified column interpolator (the LP version), but does not require the input column c1 to be increasing. Unless I'm missing something in the intended structure, I don't see any need to do any element/submatrix extractions.

Lou

Lou

Thanks for participating in the thread and for the example.

The function you and Richard provided are both compatible with descending columns of data, but your function extrapolates out of the data range, which can be a little risky.

Cheers

Mike

LouP
12-Amethyst
(To:MikeArmstrong)

What I think is Richard's function - what I named the RJ version - (from your lookup 5 file) doesn't handle descending values in param c1 - see examples at bottom of my sheet. There may be an updated version that does, but then it's not the one I copied.

I put in a trap in my version to check out-of-range values, so extrapolation will not be attempted. It should - and does per my testing - return a "value outside table range" message in such cases. Try changing the value of n in the examples at the bottom to n = 100, outside of the 0-90 range for c1=1.

Lou

MikeArmstrong
12-Amethyst
(To:LouP)

Sorry Lou my mistake.

Nice function by the way. Not quite sure on the last 'If' statement - Need a bit of time to play with it and understand how you've obtained the results.

Mike

Mike,

I will leave it there, you have a 3 cols of data as the Y's but no cols of the X's . So, I'm rendering a standard data table and linterp on a point index and proportional part, like any standard data table. It does not care sorting or whatever and no risk to interpolate outside the range of the "point index". This proposal is a 1/1 copy of another project done years ago, interpolating a scatter surface plot of only XYZ. You can have any number of cols, shuffle at will and that's it. If you would have the first column " valued", the project would just be a bit different. Before, you wanted to interpolate between columns, Valery spline does it fine, but for your late request, you give no instruction, just data that are just data .

Like before: an image in lieu of ws because of the upload/download not working.

jmG

>The function you and Richard provided are both compatible with descending columns of data< [Mike]

That, I didn't care considering that design should go with the Mathcad structure [vg: splines]

>but your function extrapolates out of the data range, which can be a little risky< [Mike/Lou]

That I didn't care either for the same reason ... and,

if the data set is really a scatter that can't be modified, nothing will do except

my proposal, but it needs a further module to first locate the indices of the analog point.

What you have there is just the introduction to the principle of the "proportional part".

Work sheet exchange does not work, an image will do, demo only.

jmG

Jean,

As you can't download worksheets I will post images of the examples posted by Lou and my modified function if you want?

Lou posted a function which will handle data in descending order, better to have a function which handles as many scenario's as possible, don't you think?

Mike

>I will post images of the examples posted by Lou and my modified function if you want ? <

___________________________-

Thanks mike,

I have my own tools doing what I need.

Jean

Jean,

Please find attached Lou's function as an image due to your downloading problems.

Mike

Announcements

Top Tags