Matlab中3D域中的2D轮廓切片 [英] 2d contourslice in a 3d domain in matlab

查看:205
本文介绍了Matlab中3D域中的2D轮廓切片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据文件,其中包含变量V的x,y,z坐标

i have a data file which contains the x,y,z coordinates of the variable V

x                   y   z                   V 
0                   0   0.500000000000000   3.91743717285931
0.0500000000000000  0   0.500000000000000   4.82593865902504
0.100000000000000   0   0.500000000000000   5.03874568425820
0.150000000000000   0   0.500000000000000   4.84015746128314
0.200000000000000   0   0.500000000000000   4.31320834211277
0.250000000000000   0   0.500000000000000   4.71007310928003
0.300000000000000   0   0.500000000000000   5.68353172300361
0.350000000000000   0   0.500000000000000   6.93907354201857
0.400000000000000   0   0.500000000000000   1.69713115593222
0.450000000000000   0   0.500000000000000   0
0.500000000000000   0   0.500000000000000   0
0.550000000000000   0   0.500000000000000   0
0.600000000000000   0   0.500000000000000   0.485840981213434
0.650000000000000   0   0.500000000000000   1.30265381445392
0.700000000000000   0   0.500000000000000   1.73892191516507
0.750000000000000   0   0.500000000000000   1.78720066586633
0.800000000000000   0   0.500000000000000   0.401158585618868
0.850000000000000   0   0.500000000000000   4.33700792828408
0.900000000000000   0   0.500000000000000   5.76388423361443
0.950000000000000   0   0.500000000000000   2.41835943394263

由于包含值的数据文件都在单独的列中,因此我正在尝试将整个doamin转换为单个3d doamin.

as the data file which contains the values are all in separate columns i am trying something this to convert the whole doamin into a single 3d doamin.

input = importdata('lci_000210.dat',' ',3);
nx = 96;
ny = 96;
nz = 49;

x = input.data(:,1);
y = input.data(:,2);
z = input.data(:,3);
Lci = input.data(:,4);


L3d = reshape(Lci,[nx,ny,nz]); 
x3d = reshape(x,[nx,ny,nz]);
y3d = reshape(y,[nx,ny,nz]);
z3d = reshape(z,[nx,ny,nz]);


[x3d,y3d,z3d,L3d] = flow;
xslice = 5;
yslice = 0;
zslice = 0;
slice(x,y,z,Lci,xslice,yslice,zslice);
view(25,20);
colormap jet
colorbar

但这会不断引发以下错误

this however keeps throwing up the following error

V must be a 3-D array.

所以我真的不确定如何处理数据集,我真正想要的是在数据集中的任何位置进行切片,但仍显示3d doamin.我已附上一张图片,显示我希望如何表示该切片.我曾尝试过重新塑形,但这种方法不起作用,我已经完成了重新塑形,因为数据在列中,并且重新塑形将其变成了应有的3d矩阵.

So i am really unsure how to deal with the dataset, what i really would like is to take a slice at any location through the dataset, but still show the 3d doamin. i have attached a picture showing how i would like the slice to be represented. I have tried re-shape but that is not working, i jave done re-shape as the data is in columns and re-shape turns it into a 3d matrix as it should be.

数据来自流体流动模拟

关于如何从此数据集中获取切片的任何建议和帮助都将非常有用.

Any advice and help will be extremely helpful on how to get the slices from this data set.

在图像中它在y = 0处显示了轮廓切片,但我希望将其显示在任何y位置,因此可以看到从完整的3d图片中获取切片的位置

in the image it shows a contourslice at y=0, but i would like it to be shown at any y position, so the it can be seen where the slice has been taken from the full 3d picture

推荐答案

问题似乎出在您的x3d和y3d颠倒了.

The problem seems to be your x3d and y3d are reversed.

slice(y3d,x3d,z3d,L3d,[],[],[0.1 0.3 0.5]);
ax=gca;
ax.Children(1).LineStyle='none';
ax.Children(2).LineStyle='none';
ax.Children(3).LineStyle='none';
view(25,20);
colormap jet
colorbar

对于轮廓,只需给它一个值即可绘制轮廓.

For contours just give it a value to draw the contour of.

figure(2);clf
contourslice(y3d,x3d,z3d,L3d,[],[],[0.1 0.3 0.5],[10 20]);
view(25,20);

对于轮廓图,我找到了另一种解决方案.不像其他两个那么简单.

For contourplots I found a different solution. Not as straightforward as the other two.

zax = squeeze(z3d(1,1,:));
zvals=[2 13 24];
figure(1);clf;hold on
for ct = 1:length(zvals)
    %plot the contour
    contourf(L3d(:,:,zvals(ct)),[0 10 20]);
    ax=gca;
    ax.Children(1).XData=x3d(:,1,1); %set x axis
    ax.Children(1).YData=y3d(1,:,1); %set y axis
    ax.Children(1).ContourZLevel=zax(zvals(ct)); %put at correct z
end
view(25,20);colormap

在此感谢Amro的回答:在一个3d图形[Matlab]中绘制多个2d等高线图

Thanks to Amro's answer here: plot multiple 2d contour plots in one 3d figure [Matlab]

这篇关于Matlab中3D域中的2D轮廓切片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆