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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

data sets/function

payman
13-Aquamarine

data sets/function

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:payman)

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.

View solution in original post

7 REPLIES 7
Werner_E
24-Ruby V
(To:payman)

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.

payman
13-Aquamarine
(To:Werner_E)

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.

Werner_E
24-Ruby V
(To:payman)

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?

1.png

payman
13-Aquamarine
(To:Werner_E)

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.

Werner_E
24-Ruby V
(To:payman)

See if the attached file helps.

payman
13-Aquamarine
(To:Werner_E)

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?

Werner_E
24-Ruby V
(To:payman)

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.

Top Tags