2016-05-23 12 views
0

私はこのグラフ上のいくつかの点を補間するinterp1機能を使用していますが補間は、X-ベクトル

enter image description here

私の問題は、私は新しいポイントを等間隔にしたいということです。しかし、interp1関数では、入力引数はx(before),y(before)x(new)であり、輪郭距離ではなく垂直座標です。

私の問題を解決する他の機能があるのですか?そうでない場合は、どのように私はxベクトルを変換することができます知っていますか?

EDIT:

たとえば私の問題ではここにある:

x=0:0.1:10; 
y=x.^4; 

xx=linspace(min(x),max(x),10); 
yy=interp1(x,y,xx); 

hold on; 
plot(x,y); 
plot(xx,yy); 
plot(xx,yy,'ro'); 
hold off; 
+0

はい、その行は、平歯車の足を表し、ポイントがメッシュを作成するための最初のステップです。 – Antreas

+0

もしあなたが曲線の方程式を持っていれば、これは[微積分の微積分](https://en.wikipedia.org/wiki/Calculus_of_variations)の問題として解けると思います。数値的には、等密度分布の問題として解くことができます(rho(x)= sqrt(1+)のメッシュ密度を取る私の答え[ここ](http://scicomp.stackexchange.com/a/21849/17671)参照) u_x)^ 2) 'ここで、' u_x'はあなたの曲線の一次導関数です。 – Steve

答えて

1

あなたはlength along the curveのパラメトリック関数として、あなたの曲線を改質することによってこれを行うことができます。あなたが望むのは、(補間する)最終点の長さが等しいことです。元のデータ点をつなぐ区分線形曲線として '真の'曲線を近似することでこれを行うことができます。

% make some fake data 
% triple exponential function has nonuniform spacing 
x = linspace(.4, .8, 20)'; 
y = exp(exp(exp(x))); 
x = (x - min(x)) ./ range(x); 
y = (y-min(y)) ./ range(y); 
xy = [x, y]; 

曲線に沿った各点の長さを見つけ、:

は、各行がポイントであり、x/y座標が列の1/2にある場合、我々はマトリックスxyにいくつかのデータポイントがあると最初の時点では0から始まる:今

% distance of each point from previous point 
% note that points need to be in order 
ds = [0; sqrt(sum(diff(xy, 1, 1) .^ 2, 2))]; 

% integrate to find length along the curve 
s = cumsum(ds); 

sの関数であることがxyの両方を考慮してください。曲線に沿って等間隔長さの組でxyを補間:

% find a set of equally spaced lengths along the curve 
si = linspace(s(1), s(end), 20)'; 

% interpolate x and y at these points 
xyi = interp1(s, xy, si); 

溶液が機能することを確認:

% distance between successive interpolated points 
% they should all be equal 
sqrt(sum(diff(xyi, 1, 1) .^ 2, 2) 

オリジナルデータ:

enter image description here

補間:

enter image description here