[英]Matlab 2d contour plot in 3d
這只是關於如何使用contourslice
工作的粗略想法:
p = peaks(21);
contourf(p);
view(25,20);
插入您的數據而不是peaks(21)
並注意尺寸。 然后你可以做類似的事情
%Get a grid for your data. x and z have dimensions of your old data grid,
%y will is used to build a volume, which will have three slices with the
%data, which is necessary because contourslice takes a volume, not a surface
x = -2:0.2:2;
y = -0.1:0.1:0.1;
z = -2:0.2:2;
[X,Y,Z] = meshgrid(x,y,z);
%Make your data matrix (which is 2D so far) 3D by repeating 3 times in Z
u = repmat(p, [1, 1, 3]);
Sx = []; %No planes to be drawn orthogonal to X
Sy = 0; %One plane to be drawn orthogonal to Y
Sz = []; %No planes to be drawn orthogonal to Z
%Only draw one of your three y planes. Change X and Z.
figure;
contourslice(X,Y,Z,permute(u,[3, 2, 1]),Sx,Sy,Sz)
view(25,20);
要得到
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.