Asked by Stelios Fanourakis
on 29 Oct 2019

Hi

I have two datasets with different dimensions. Needs to be matched somehow and one dimension needs to be interpolated to fit the dimension of the second data set

My first dataset is X,Y (2D) and my second dataset is only Y (1D). I need to somehow combine those two datasets. Like trying to plug in the Y axis data from the second dataset to the first set which is 2D. So, the X axis from the first set will be interpolated to match the data of the new Y axis data (second set). Am I clear?

Answer by the cyclist
on 30 Oct 2019

% Data from your file that has both x and y

x1 = [2 3 5];

y1 = [1 2 3];

% Data from your file that has only y

y2 = [1.5 2.5];

% Interpolate the set of x data in based on the above.

x2 = interp1(y1,x1,y2)

If you look at that documentation page, note that the use of "x" and "y" variables are swapped compared to what is written here, because the normal convention is that y is dependent on x, but that is not what you have described in your question.

If this doesn't do what you want, or if it is unclear, then I suggest you actually load your data from Excel into MATLAB, save to a *.mat file, and upload those data here.

the cyclist
on 31 Oct 2019

Still a little unclear, and still no data to look at.

Are you saying that the value of X doesn't matter to the calculation? Can you simply interpolate force from strain (y), using the formula I posted?

Stelios Fanourakis
on 1 Nov 2019

the cyclist
on 1 Nov 2019

% Data from your file that has both force and y

force1 = [2 3 5];

y1 = [1 2 3];

% Data from your file that has only y

y2 = [1.5 2.5];

% Interpolate the set of force data in based on the above.

force2 = interp1(y1,force1,y2)

Same as I posted above, but I've just changed variable names since you are interpolating force from y.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## the cyclist (view profile)

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/488134-interpolate-among-datasets-so-one-set-matches-the-other#comment_761375

## Stelios Fanourakis (view profile)

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/488134-interpolate-among-datasets-so-one-set-matches-the-other#comment_761654

Sign in to comment.