20.11 M
文件例子
精?/p>
MATLAB
工具?/p>
含有许多实用函数,它们可以验证本章的许多概念。这些函数的?/p>
本部分已经在二维和三维图形这些章阐述过了。有了前面对句柄图形的讨论,我们现在可以?/p>
彻底地讨论这些函数?/p>
最简单的
精?/p>
MATLAB
工具?/p>
的函数之一提出了一个共同的问题?/p>
MATLAB
函数
gcf
?/p>
回当?/p>
图形
的句柄。但是,它有一个副作用。如?/p>
图形
不存在,
gcf
就创建一个,并返回它?/p>
句柄。如果想寻找一?/p>
图形
是否存在于头一个位置,要是没有,又不得不创建,怎么办?函数
mmgcf
正好实现由其内容所描述的工作?/p>
function HF=mmgcf
%MMGCF Get Current Figure if it Exists.
%
MMGCF returns the handle of the current figure if it exists.
%
If no current figure exists,MMGCF returns an empty handle.
%
%
Note that the function GCF is different.It creates a figure and returns its handle if it does not
%
exist.
%
Copyright
(c)
1996 by Prentice-Hall,Inc.
Hf=get(0,
?/p>
Children
?/p>
);
%
check for figure children
if isempty(Hf)
return
else
Hf=get(0,
?/p>
CurrentFigure
?/p>
);
end
函数
mmgcf
首先检?/p>
?/p>
对象的子对象?/p>
图形
是否存在?/p>
如至少有一?/p>
图形
对象时,
?/p>
对象
?/p>
?/p>
CurrentFigure
?/p>
属性就返回当前?/p>
图形
?/p>
函数
mmgca
?/p>
坐标?/p>
对象执行同样的功能,如同在它?/p>
M
文件内所描述的那样?/p>
function Ha=mmgca
%MMGCA Get Current Axes if it exists.
%
MMGCA returns the handle of the current axes if it exists.
%
If no current axes exists,MMGCA returns an empty handle.
%
%
Note
that
the
function
GCA
is
diffent.It
create
a
figure
and
an
axes
and
returns
the
axes
%
handle if they do not exist.
%
Copyright
(c)
1996 by Prentice-Hall,Inc.