简体   繁体   English

Matlab分散数据的4D插值图

[英]4D interpolation plot with matlab of scattered data

I have a set of data with a value at some x,y,z coordinates. 我有一组数据,值在某些x,y,z坐标上。 However, the coordinates are not evenly spaced. 但是,坐标不是均匀间隔的。 I would like to interpolate the data and have a 3D interpolated plot where the color is the interpolated value at each x,y,z coordinates (not the value of z). 我想对数据进行插值,并有一个3D插值图,其中颜色是每个x,y,z坐标上的插值(而不是z的值)。

Also I should mention that my data are confined in space and I only want to interpolate between points that are close. 我还要提到的是,我的数据仅限于空间,我只想在接近的点之间进行插值。 I have multiple sheet-like structures and I do not want interpolation between the sheets. 我有多个类似图纸的结构,并且我不想在图纸之间进行插值。 I would therefore need a distance between points criteria I guess. 因此,我猜想在点标准之间需要一个距离。

My problem can be seen with this MATLAB test program 我的问题可以在这个MATLAB测试程序中看到

x = rand(100,1)*16 - 8;
y = rand(100,1)*16 - 8;
z = rand(100,1)*16 - 8;
d = rand(100,1)*16 - 8;

The scatter plot of that works very well 散点图效果很好

scatter3(x,y,z,5,d);
colormap(jet);
colorbar;

I would like to have an nice surface with color of that. 我想有一个漂亮的颜色的表面。 Of course the interpolation of the above will be very bad since it is random points and color(value) but for my case it has more meaning. 当然,上面的插值将是非常不好的,因为它是随机点和颜色(值),但对我而言,它具有更多的含义。

Any ideas on how to accomplish this? 关于如何做到这一点的任何想法?

Edit 编辑

I shall emphasize the localized nature of my problem (see picture below using scatter3). 我将强调问题的局部性(请参见下面的图片,使用scatter3)。

局部插值问题。

The very interesting solution proposed by Suever using scatteredInterpolant on the same data as the first figure gives me the following picture Suever提出的非常有趣的解决方案是在与第一个图相同的数据上使用了分散的插值,这给了我以下图片

插值图片

Thank you, 谢谢,

Samuel 塞缪尔

Since your input data is scattered, you're going to want to use scatteredInterpolant . 由于您的输入数据是分散的,因此您将要使用scatteredInterpolant This allows for interpolation of non-uniformly-spaced input data. 这允许对非均匀间隔的输入数据进行插值。

For your specific data, you would use something similar to the following where xq , yq , and zq are the points at which you want to interpolate the input. 对于您的特定数据,您将使用类似于以下内容的内容,其中xqyqzq是要对输入进行插值的点。

S = scatteredInterpolant(x,y,z,d);
values = S(xq,yq,zq);

As far as your specific conditions on the definition of neighboring data, you'll want to look at the various interp methods provided for scatteredInterpolant to see if any of them meet your needs. 至于你对邻近数据的定义特定的条件下,你会想看看不同的插补方法提供scatteredInterpolant ,看看其中是否满足您的需求。

Edit 编辑

Upon closer reading, it seems like you may want to interpolate both z and d over a regular grid. 仔细阅读后,似乎您可能希望在常规网格上同时插入zd If that's the case, you can still use scatteredInterpolant in the following way. 如果是这种情况,您仍然可以通过以下方式使用scatteredInterpolant的Interpolant。

% First interpolate for z
S = scatteredInterpolant(x,y,z);

xrange = linspace(min(x), max(x), 1000);
yrange = linspace(min(y), max(y), 1000);

[xq, yq] = meshgrid(xrange, yrange);

% These are now the interpolated z values (height of surface)
znew = S(xq,yq);

% Now we want to use x,y,z to interpolate d at the new grid points
S = scatteredInterpolant(x,y,z,d);

% Interpolate d at the new points
dnew = S(xq, yq, znew);

So we apply this to the random data you've provided, we can plot a surface like you were talking about. 因此,我们将其应用于您提供的随机数据,我们可以像您在说的那样绘制表面。

S = surf(xq, yq, znew, 'CData', dnew);

在此处输入图片说明

The original data points (x,y,z) are shown as a scatter plot with black outlines. 原始数据点(x,y,z)显示为带有黑色轮廓的散点图。 You can see that the data interpolates these points and the color of the surface should also be interpolated from these points. 您可以看到数据对这些点进行了插值,并且表面的颜色应从这些点进行插值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM