# Interpolate among Datasets so one set matches the other

53 ビュー (過去 30 日間)
Stelios Fanourakis 2019 年 10 月 29 日
コメント済み: Image Analyst 2020 年 7 月 26 日
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?
##### 2 件のコメント表示非表示 1 件の古いコメント
Stelios Fanourakis 2019 年 10 月 30 日
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.

サインインしてコメントする。

### 回答 (2 件)

the cyclist 2019 年 10 月 30 日
% 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.
##### 9 件のコメント表示非表示 8 件の古いコメント
the cyclist 2020 年 7 月 21 日
You should really open a new question, rather than burying this as a comment on an 8-month-old question.
But, since I happened to see it ...
You'll need to separate your problem into two different "branches" of y, because the sample points must be unique. So, you'll need to do one interpolation with, for example, the values of y>=0, and another with y<0.

サインインしてコメントする。

MOHD UWAIS 2020 年 7 月 26 日
Actually my problem is to find the fwhm(s) of large number of curve like following. So i require the interpolation values of x corresponding to average y values to write the code (because x values do not lie exactly y data points in average of y) . There are exist two values of x correspondinfg to single average value of y in a one curve (therfore sample point is not unique).
i looking forwrd.
Thank YOU.
##### 1 件のコメント表示非表示 なし
Image Analyst 2020 年 7 月 26 日
but you still posted your question here, as an answer to Stelios's question. Why?
We look forward to answering your question when you post it as your own question, not here in Stelios's thread. In the meantime, check out the find() function, like index=find(signal < threshold).

サインインしてコメントする。

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by