Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- data sets/function

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-14-2014
10:53 AM

09-14-2014
10:53 AM

Hello,

I have 2 sets of data, X and Y, with the same length.

How can I express one set as a function of the other one: Y(X)

Thank you.

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-15-2014
06:48 PM

09-15-2014
06:48 PM

PAYMAN RAJAI wrote:

Thank you it works. There is just one question. Is there any chance that interpolation disturb my original data?

? How could your original data be disturbed? As long as you input an element of vector X, you will receive the exact associated element of vector Y. If you input an x-value inbetween you will get an y-value inbetween. Any interpolation will return vector Y if you feed it with vector X. This is not the case if you use approximation (regressions).

Is "linterp" the best function for this job?

Which job?

You will find quite some other interpolations like various splines (bspline, cspline, pspline. lspline) in Mathcads toolbox. Which one is "the best" depends on your needs.

Every interpolation will map vector X onto vector Y. The diffrences are what the interpolation does with the values inbetween the values in X.

7 REPLIES 7

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-14-2014
11:55 AM

09-14-2014
11:55 AM

Re: data sets/function

This can be done either by using interpolation or approximation (regression).

Which one would you prefer?

The problem is that for any interpolation X has to be sorted in ascending order with no duplicate values.

You have a lot of duplicates in your vector X.

E.g. your first values in X are all 6 380 0000 which will make the interpolation to throw an error. The corresponding values in Y are different, so what result would you expect for y(63800000)? You have the choice from -0.0325 downto -0.0312.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-14-2014
12:25 PM

09-14-2014
12:25 PM

Re: data sets/function

Werner, I just want to assign each Y component to its corresponding X component. (No interpolation)

later in my program I will recall Y(X) for some particular X components.

From the graph of Y vs X, it is seen thant no two components of X are the same.

Thank you.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-14-2014
12:47 PM

09-14-2014
12:47 PM

Re: data sets/function

PAYMAN RAJAI wrote:

Werner, I just want to assign each Y component to its corresponding X component. (No interpolation)

But you want to create a function. What should the function return if its argument is 6385000?

Your data will only provide values for 6380000 and 6390000? A function will have to return a value!

later in my program I will recall Y(X) for some particular X components.

Sound more complex than necessary, but you could create a function using Mathcads builtin lookup function and you will have to decide what should happen if you feed it with a value not available in X - lookup will throw an error which you can catch with an "on error".

But again, lookup(6380000,X,Y) will give you a vector with seven values, because of the many duplicates in your data.

From the graph of Y vs X, it is seen thant no two components of X are the same.

Thank you.

What do you think you can see by looking at the full plot. Look at the data itself or zoom in. The first seven values in X ARE the same and the associated Y values are all different. This is not only the case for the first seven values but happens all over throughout the whole data range.

So again, what would you like Y(6400000) to return? You have the choice amongst 14 different Y-values.

See the image below. I zoomed in to show just the first 35 data points. Do you still think that you have no duplicate X values?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-15-2014
01:06 AM

09-15-2014
01:06 AM

Re: data sets/function

Oh, I see what you mean. Sorry this is because I just transferred the data from my program. I have attached my program that generates the data.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-15-2014
03:34 AM

09-15-2014
03:34 AM

Re: data sets/function

See if the attached file helps.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-15-2014
11:04 AM

09-15-2014
11:04 AM

Re: data sets/function

Thank you it works. There is just one question. Is there any chance that interpolation disturb my original data? Is "linterp" the best function for this job?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-15-2014
06:48 PM

09-15-2014
06:48 PM

PAYMAN RAJAI wrote:

Thank you it works. There is just one question. Is there any chance that interpolation disturb my original data?

? How could your original data be disturbed? As long as you input an element of vector X, you will receive the exact associated element of vector Y. If you input an x-value inbetween you will get an y-value inbetween. Any interpolation will return vector Y if you feed it with vector X. This is not the case if you use approximation (regressions).

Is "linterp" the best function for this job?

Which job?

You will find quite some other interpolations like various splines (bspline, cspline, pspline. lspline) in Mathcads toolbox. Which one is "the best" depends on your needs.

Every interpolation will map vector X onto vector Y. The diffrences are what the interpolation does with the values inbetween the values in X.