2

次のような一連のデータがあります。

!Sr.#    x-coord.    y-coord     potential at (x,y)
  1       0.0000     1.0000      0.3508
  2       0.7071     0.7071      2.0806
  .       ....       ....        ....
  .       ....       ....        ....
 1000    0.0000     -1.0000      0.5688

上記のデータの 2D 等高線を生成する必要があります。2D 等高線マップの対応する (x,y) 位置にポテンシャルの値がプロットされます。Matlab の等高線コマンドを使用して 2D 等高線をプロットできるようにするには、2D マトリックスを使用する必要があると思います (私の場合、基本的に潜在的な値が含まれます)。この場合の 2D マトリックスを作成するにはどうすればよいですか? または、2D マトリックスを完全に回避し、2D 輪郭を与えることができる回避策があります。私が持っている xy 座標データは特定の順序ではありませんが、必要に応じて配置できます。

4

2 に答える 2

2

私は自分でこの問題に遭遇し、stackoverflow メンバーのJohn D'Errico、つまりウッドチップから信じられないほどの解決策を見つけました。Matlab Central にある彼のパッケージgridfit,は、問題を簡単に解決してくれます。これは私自身の例ですが、John のすばらしいドキュメントとデモ ファイルには、はるかに優れた例があります。

% first, get some random x,y coordinates between -3 and 3
% to allow the peaks() function to look somewhat meaningful
x = rand(10,1)*6 - 3;
y = rand(10,1)*6 - 3;
% calculate the peaks function for this points
z = peaks(x,y);
% now, decide the grid we want to see, -3 to 3 at 0.1 intervals
% will be fine for this crude test
xnodes = -3:0.1:3;
ynodes = -3:0.1:3;
% now, all gridfit, notice, no sorting!  no nothing!
% just tell it the rectangular grid you want, and give it
% the raw data.  It will use linear algebra and other robust
% techniques to fit the function to the grid points
[zg,xg,yg] = gridfit(x,y,z,xnodes,ynodes);
% finally, plot the data, Viola!
contour(xg,yg,zg)
于 2013-02-19T23:04:31.393 に答える
1

任意に散らばったデータについては、gridfit の代わりにTriScatteredInterpを調べてください。

于 2013-09-27T19:50:01.897 に答える