## Interpolate among Datasets so one set matches the other

Stelios Fanourakis

### Stelios Fanourakis (view profile)

님이 질문을 제출함. 29 Oct 2019
최근 활동 the cyclist

### the cyclist (view profile)

님이 댓글을 추가함. 1 Nov 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?

the cyclist

### the cyclist (view profile)

29 Oct 2019
When you say "datasets" do you mean the actual MATLAB dataset variable type? If not, how are your data stored? Can you upload a MAT file with the actual data (or a small, representative sample)?
Stelios Fanourakis

### Stelios Fanourakis (view profile)

30 Oct 2019
Datasets are two different excel files. Both they have the same X axis but are changed in Y axis. I want to plug in the Y values of the second set to the first one and interpolate. E.g. if the Y values are in Newtons and there are thickness changes of a material vertically (compressive forces) for every X there is a Y value (Newton) caused the deformation or the change in thickness (shape). For different Y values (second set of excel data), needs to interpolate the appropriate forces.

로그인 to comment.

## 답변 수: 1

the cyclist

### the cyclist (view profile)

님의 답변 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)
Here is a simple example using the interp1 function. I'm not certain if this is what you mean.
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.

표시 이전 댓글 수: 4
the cyclist

### the cyclist (view profile)

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

### Stelios Fanourakis (view profile)

1 Nov 2019
yes actually x is stable. X is the lenght of the object and it stays the same since the force is vertical and compressive. So only y values are changing and the force vector which may be considered as the third variable. So, you suggest me to interpolate among y and forces and keep x stable. I will consider that one. Thanks again. If possible provide me a code. Thanks
the cyclist

### the cyclist (view profile)

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.

로그인 to comment.