一个matlab画四维图的例子
昨天在群里问了大家,现在把做的过程发出来。这个问题相当于有限元里面后处理的例子。一个数组一共四列,前三列为坐标xyz,第四列为温度。
clear
clc
data=load('c:/nodetemp.txt')
sx=0:0.2/5:0.2
sy=0:0.3/5:0.3
sz=0:0.2/5:0.2
v=zeros(6,6,6)
for index=1:216
if (data(index,1)-0.00)<1e-5
xbiao=1
elseif (data(index,1)-0.04)<1e-5
xbiao=2
elseif (data(index,1)-0.08)<1e-5
xbiao=3
elseif (data(index,1)-0.12)<1e-5
xbiao=4
elseif (data(index,1)-0.16)<1e-5
xbiao=5
elseif (data(index,1)-0.2)<1e-5
xbiao=6
end
if (data(index,2)-0.00)<1e-5
ybiao=1
elseif (data(index,2)-0.06)<1e-5
ybiao=2
elseif (data(index,2)-0.12)<1e-5
ybiao=3
elseif (data(index,2)-0.18)<1e-5
ybiao=4
elseif (data(index,2)-0.24)<1e-5
ybiao=5
elseif (data(index,2)-0.3)<1e-5
ybiao=6
end
if (data(index,3)-0.00)<1e-5
zbiao=1
elseif (data(index,3)-0.04)<1e-5
zbiao=2
elseif (data(index,3)-0.08)<1e-5
zbiao=3
elseif (data(index,3)-0.12)<1e-5
zbiao=4
elseif (data(index,3)-0.16)<1e-5
zbiao=5
elseif (data(index,3)-0.2)<1e-5
zbiao=6
end
v(xbiao,ybiao,zbiao)=data(index,4)
end
= meshgrid(0:0.2/5:0.2,0:0.3/5:0.3,0:0.2/5:0.2)
slice(x,y,z,v,data(:,1),data(:,2),data(:,3))
colorbar
读入的txt文件:
结果图形:
这样的方法没代表性吧。 说白了,就是把这些node练成多边形,然后根据结点的温度填上结点的颜色。因为软件填色的本身设定,整个多边形就填上色。Matlab 可以做,Mathematica也可以做。因为你把那些结点关系省略了,我就用Interpolation来补充一下了。
[*]data = Import["C/nodetemp.txt", "Table"]
[*]data1 = Transpose[{data[], data[]}];
[*]b = Max@data[];
[*]a = Min@data[];
[*]ff = Interpolation
[*]tt = RegionPlot3D[
[*] 0 <= x <= 0.2 && 0 <= y <= 0.3 && 0 <= z <= 0.2, {x, 0, 0.2}, {y,
[*] 0, 0.3}, {z, 0, 0.2}, Mesh -> {8, 5, 6}, PlotPoints -> {10, 7, 8},
[*] MaxRecursion -> 0];
[*]cls = Map[(ColorData["TemperatureMap"][(ff @@ # - a)/(b - a)]) &,
[*] tt[]];
[*]Row[{Graphics3D[{GraphicsComplex[
[*] tt[], {Opacity, EdgeForm[],
[*] Cases], Polygon, {0, Infinity}]},
[*] VertexColors -> cls]}, Axes -> True,
[*] AxesLabel -> {"x", "y", "z"}, Boxed -> False, BoxRatios -> 1,
[*] ViewPoint -> {-2, -2, 1}, ImageSize -> 350],
[*]Graphics[DensityPlot[(y - a)/(b - a), {x, 0, 0.5}, {y, 22, 25},
[*] ColorFunction -> (ColorData["TemperatureMap"][#1] &)][],
[*] Ticks -> {None, Range}, Frame -> False, Axes -> True,
[*] AspectRatio -> 10, ImageSize -> 45]}, Spacer]
得到:
页:
[1]