如何使用matlab可视化/绘制温度梯度?

时间:2012-01-18 12:17:59

标签: matlab

One side should look like this, depending upon temperature values a smooth description enter image description here我在3D矩形的特定点有数据,我想看温度梯度。我在特定点有值,但我希望每个传感器之间有连续的梯度流。我无法弄清楚如何在放置在不同点的每个传感器之间可视化或映射数据。坚持:(

X=[5 0 0 0 0 5 10 10 10 10 0 5 10 10 0 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 0 5 10 0 5 10 10 10 5 0 0]';
Y=[10 10 5 5 10 10 5 10 5 10 0 0 0 0 0 0 3.5 7 3.5 7 3.5 7 3.5 7 3.5 7 3.5 7 3.5 7 3.5 7 0 0 0 0 0 0 5 10 10 10 5 ]';
Z=[20 20 20 14 14 14 14 14 20 20 20 20 20 14 14 14 3.8 3.8 0 0 7.5 7.5 10 10 12.5 12.5 15 15 17.5 17.5 20 20 0 0 0 7.5 7.5 7.5 7.5 7.5 7.5 7.5 7.5]';
%# temperature vector
T = [20 22 24 22.1 26.1 22.4 15 17 21 22 19 22 18 17 18 20 21 22 21 24 22.3 22.5 22.8 28.9 22 27 26 20 19 24 21 23 19 18 22 25 27 21 29 25 22 21 22];
scatter3(X,Y,Z,[4000],T,'.');
grid off
box off
view(32,18); axis equal tight off vis3d; % azimuth 26
camproj perspective
camlight; lighting gouraud; alpha(0.75);
rotate3d on

下面的代码只显示了我的3d矩形的一面应该是什么样子(它只是一个随机代码)

datagrid = 500*peaks(100);
R = makerefmat('RasterSize',size(datagrid));
[aspect,slope,gradN,gradE] = gradientm(datagrid,R);
figure; axesm eqacyl
meshm(datagrid,R)
colormap (jet(64))
colorbar('vert')
title('Peaks: elevation')
axis square

1 个答案:

答案 0 :(得分:1)

您可以将问题分解为两个子问题:

  • 插值
  • 可视化

我们先来看看插值。有很多方法可供使用,但让我们试试MATLAB函数griddatan。这会将(线性)值插值到一组新的点上(这里我使用了使用meshgrid构造的常规网格)。

M = 20;
N = 20;
L = 40;

T = transpose(T);

% Set up the grid of points we wish to interpolate at
[xi,yi,zi] = meshgrid(linspace(0,10,M),linspace(0,10,N),linspace(0,20,L));

% Perform interpolation
ti = griddatan([X,Y,Z],T,[xi(:),yi(:),zi(:)]);

% Reshape back from a column vector to a MxNxL matrix
ti = reshape(ti, size(xi));

% Visualise in some way
scatter3(xi(:),yi(:),zi(:),400,ti(:),'.')

在可视化方面,天空是极限,3D体积可视化更像是一门艺术而非科学。我担心我无法运行你的例子(我无法访问makerefmat),但http://www.mathworks.co.uk/help/techdoc/visualize/bqliccy.html有一些很好的起点。