Octave:绘制3D插值的结果

时间:2015-01-19 16:58:52

标签: plot octave interpolation

我想绘制一个表面,其高程是分散数据上3D插值的结果: 我有三个列向量中的坐标x,y,z和标量值v。我想插入v,例如,一个常数x平面,坐标为xi,yi,zi,获得vi,最终绘制表面(yi,zi,vi)。 我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

这是我找到的解决方案,感谢andy1978在#octave irc频道和Nicola:

x1 = linspace (min(x),max(x),50) ;
y1 = linspace (min(y),max(y),50) ;
z1 = linspace (min(z),max(z),50) ;
[xx, yy, zz] = meshgrid (x1, y1, z1) ;

vv = griddata3 (x, y, z, v, xx, yy, zz ) ;

x0 = 0.05 ;   % constant x of chosen plane

[~,i] = min (abs (x - x0)) ;

vv_sect = vv (:, i, :) ;      % here I slice the matrix of interpolated results at x=x0
vv_out = squeeze (vv_sect) ;  % and this is what I needed to reduce the dimensionality of
                              % the sliced matrix

[yy2,zz2] = meshgrid (y1, z1) ;

surf (yy2, zz2, vv_out ) ;