kanhlbai 发表于 2011-4-11 21:25

请教:如何移动空间云图的位置?多谢!

利用函数surf(cx, cy,cz)画了一个空间的曲面,之后用contourf(cx,cy, cz)画了一个空间云图。但是,这个云图的位置是在xy平面内(z=0),现在想移动这个云图的位置到z=zo,如何实现?多谢!

messenger 发表于 2011-4-11 22:34

可以通过调整等高线句柄来实现。如果你有权限看simwe的帖子,这有更详细的讨论http://forum.simwe.com/thread-885324-1-1.html

kanhlbai 发表于 2011-4-11 22:36

本帖最后由 kanhlbai 于 2011-4-11 22:37 编辑


谢谢,但是看不了哦。

kanhlbai 发表于 2011-4-11 22:43

messenger 发表于 2011-4-11 22:34 static/image/common/back.gif
可以通过调整等高线句柄来实现。如果你有权限看simwe的帖子,这有更详细的讨论http://forum.simwe.com/thre ...

麻烦给解释一下吧,谢谢!

kanhlbai 发表于 2011-4-12 08:57

望高手给解答一下,多谢!

kanhlbai 发表于 2011-4-12 11:50

请高手帮忙阿

ChaChing 发表于 2011-4-12 14:28

在simwe两位高人的方式, 本想直接贴过来, 但觉得应本人...
就大略描述下
1.bainhome採用修改原*.m的方式
2.rocwoods採用修改句柄的'zdata'属性

本想用axes控制, 但无对应三维的
又想到放大surf(cx,cy,cz)中的cz骗过再hold on, 函数用法模糊记错了, 行不通
当然开始help各关键词, 看看有无现成方便的, 真一时没找到适当的
最终想到跳过contourf的思维直接使用slice, 不知可否
但个人不很熟slice, 练了一下

= peaks(30); surf(X,Y,Z); hold on;
X2=repmat(X,); Y2=repmat(Y,); V2=repmat(Z,);
Z2=repmat(0*X,); Z2(:,:,1)=-40*ones(size(X));
hs=slice(X2,Y2,Z2,V2,[],[],-30); set(hs,'FaceColor','interp','EdgeColor','none')

kanhlbai 发表于 2011-4-12 14:49

ChaChing 发表于 2011-4-12 14:28 static/image/common/back.gif
在simwe两位高人的方式, 本想直接贴过来, 但觉得应本人...
就大略描述下
1.bainhome採用修改原*.m的方式
...

多谢ChaChing,前面两个高人的帖子我已经搜索到并弄明白了,他们的方法在contour3, surfc里面都可以的,但是似乎不适用于contourf函数,因为我 edit contourf 之后,没有找到有关z位置的语句,估计在contourf里面云图的位置都是缺省在z=0?

我也想是不是应该用slice,刚才都在看帮助,不过还是一头雾水。ChaChing真是及时雨啊,谢谢!

kanhlbai 发表于 2011-4-12 15:15

不好意思,又不理解 repmat 的用法了;还有,我需要在云图上加contour,即等值线?谢谢!

kanhlbai 发表于 2011-4-12 20:45

这个问题还没有琢磨明白,请大家继续指点!多谢!

ChaChing 发表于 2011-4-13 00:09

本帖最后由 ChaChing 于 2011-4-13 00:11 编辑

官网找到一个可能符合(我还没空细看并试), LZ先试试看, 结果再分享!
Make a contour plot in the xy-plane at a specific height
http://www.mathworks.com/matlabcentral/fileexchange/3500-contourz
function = contour(varargin)
%CONTOURZ Contour plot.
%   CONTOURZ(Z) is a contour plot of matrix Z treating the values in Z
%   as heights above a plane.A contour plot are the level curves
%   of Z for some values V.The values V are chosen automatically.
%   CONTOURZ(X,Y,Z) X and Y specify the (x,y) coordinates of the
%   surface as for SURF.
%   CONTOURZ(Z,N) and CONTOURZ(X,Y,Z,N) draw N contour lines,
%   overriding the automatic value.
%   CONTOURZ(Z,V) and CONTOURZ(X,Y,Z,V) draw LENGTH(V) contour lines
%   at the values specified in vector V.Use CONTOURZ(Z,) or
%   CONTOURZ(X,Y,Z,) to compute a single contour at the level v.
%   Use CONTOURZ(X,Y,Z,,height) to draw at the z value 'height'.
%    = CONTOURZ(...) returns contour matrix C as described in
%   CONTOURC and a column vector H of handles to LINE or PATCH
%   objects, one handle per line.Both of these can be used as
%   input to CLABEL. The UserData property of each object contains the
%   height value for each contour.
%
%   The contours are normally colored based on the current colormap
%   and are drawn as PATCH objects. You can override this behavior
%   with the syntax CONTOURZ(...,'LINESPEC') to draw the contours as
%   LINE objects with the color and linetype specified.
%
%   Uses code by R. Pawlowicz to handle parametric surfaces and
%   inline contour labels.
%
%   Example:
%       =meshgrid(-4:0.2:4,-4:0.2:4);
%       z=sin(sqrt(x.^2+y.^2)).^2;
%       surfl(x,y,z);
%       hold on;
%       contourz(x,y,z,'',-2);
%       contourz(x,y,z,,3);
%       hold off;
%      
%
%   See also CONTOUR, CONTOUR3, CONTOURF, CLABEL, COLORBAR.

%   Additional details:
%
%   CONTOURZ uses CONTOUR3 to do most of the contouring.Unless
%   a linestyle is specified, CONTOUR will draw PATCH objects
%   with edge color taken from the current colormap.When a linestyle
%   is specified, LINE objects are drawn. To produce the same results
%   as MATLAB 4.2c, use CONTOUR(...,'-').
%
%   Thanks to R. Pawlowicz (IOS) rich@ios.bc.ca for 'contours.m' and
%   'clabel.m/inline_labels' so that contour now works with parametric
%   surfaces and inline contour labels.

%   Copyright 1984-2001 The MathWorks, Inc.
%   $Revision: 5.17 $$Date: 2001/04/15 12:03:50 $

error(nargchk(1,5,nargin));

nin = nargin;
if isstr(varargin{end})
    nin = nin - 1;
end

if nin <= 2,
    = size(varargin{1});
    lims = ;
else
    lims = [min(varargin{1}(:)),max(varargin{1}(:)), ...
            min(varargin{2}(:)),max(varargin{2}(:))];
end

if nin>4
    height=varargin{end};
    varargin=varargin(1:end-1);
    if isempty(varargin{end}) varargin=varargin(1:end-1);end
end

= contour3(varargin{:});
if ~isempty(msg), error(msg); end

if exist('height')
   for i = 1:length(h)
       zd=get(h(i),'zdata');
       zd(~isnan(zd))=height;
       set(h(i),'Zdata',zd);
   end
else
   for i = 1:length(h)
       set(h(i),'Zdata',[]);
   end
end

if ~ishold
view(2);
set(gca,'box','on');
grid off
end

if nargout > 0
    cout = c;
    hand = h;
end

kanhlbai 发表于 2011-4-13 13:11

ChaChing 发表于 2011-4-13 00:09 static/image/common/back.gif
官网找到一个可能符合(我还没空细看并试), LZ先试试看, 结果再分享!
Make a contour plot in the xy-plane ...

感谢,这个程序和前面提到的两个高手的思路是一样的,能够把等值线在z方向移动,但是还是不能移动contourf命令生成的云图。头疼还得再继续看看怎么办。

kanhlbai 发表于 2011-4-13 20:08

继续努力之中!!!
页: [1]
查看完整版本: 请教:如何移动空间云图的位置?多谢!