Octave:绘制3D插值的结果(Octave: Plotting results of 3D interpolation)
我想绘制一个表面,其高程是散射数据上3D插值的结果:我有三个列向量中的坐标x,y,z和标量值v。 我想插入v,例如,一个常数x平面,坐标为xi,yi,zi,获得vi,最终绘制表面(yi,zi,vi)。 我怎样才能做到这一点?
I want to plot a surface whose elevation is the result of 3D interpolation on scattered data: I have coordinates x, y, z and the scalar value v in three column vectors. I would like to interpolate v on, say, a constant x plane with coordinates xi, yi, zi obtaining vi and eventually plot the surface (yi,zi,vi). How can I do that?
最满意答案
这是我找到的解决方案,感谢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 ) ;Here comes the solution I have found, thanks to andy1978 on #octave irc channel and 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 ) ;更多推荐
发布评论