About interp1 function

5 ビュー (過去 30 日間)
Mehmet Volkan Ozdogan
Mehmet Volkan Ozdogan 2019 年 7 月 22 日
回答済み: Roshni Garnayak 2019 年 8 月 5 日
Hi,
i have a data set like shown in figure1,
I try to create a new interpolate data between each sequential two data points with interp1 (one point for each sequential two data points) and the result are given in figure 2. Although i have 100 data the interpolated data are 57. It have to be 99.
It is obviously shown from figure 2 that it did not calculate interpolate data for sequential two data points. Especially sides do not have any interpolated data. What will be the solution
Thank you..
Vxi = min(Vx):0.1:max(Vx);
Vyi = interp1(Vx,Vy,Vxi, 'nearest');
plot(Vxi,Vyi, 'o')
FIGURE 1
FIGURE 2
  7 件のコメント
Jan
Jan 2019 年 7 月 24 日
You can simplify
for i=1:100
t(i)=i
end
t=t';
to the loop-free:
t = (1:100).';
Maybe it is worth to mention, that the data used to draw the diagram in the original question seem to be a 1D line. I assume they are ordered according to their X values, and not according to the outer shape, which is nearly a rectangle.
Without the input files I cannot run your code. So I still do not know, what your inputs are and what you want as output.
Mehmet Volkan Ozdogan
Mehmet Volkan Ozdogan 2019 年 7 月 24 日
Actually, input data is 3D then i used Kmeans alg. and then get 2D data for newVar ("x") and newVar2 ("*") variable, and newVar5 (O) is the mean of newVar and newVar2. They are all 2D coordinates. "X" forms the orginal cross section data of a rectangular shape, "*" is the deformed shape of same rectangular cross section. I try to find the deformation of original data ("X"). So i wanted to draw a line between O-X and * to neighbour * and then find the intersection point of these lines.And i wanted to do this for all cross section. This intersection points give me the where the original data ("X") go in second cross section.
Also you can find the data in attachment.
Thank you...

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

回答 (1 件)

Roshni Garnayak
Roshni Garnayak 2019 年 8 月 5 日
The interp1 function performs 1D interpolation and computes one y-value for the corresponding x-value. Due to this only one point is computed in the x : x+0.1 range even when a number of data points are clustered in that range.
A possible solution is to use variable interval size for Vxi. The intervals where more data points are located can be assigned smaller interval size and the intervals with lesser number of points can be allotted larger interval size.

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by