Octave:绘制3D插值的结果(Octave: Plotting results of 3D interpolation)

编程入门 行业动态 更新时间:2024-10-07 04:33:19
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 ) ;

更多推荐

本文发布于:2023-07-09 10:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1085537.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:插值   Octave   Plotting   interpolation   results

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!