2012-10-28 35 views
2

是否有任何函数可以避免m文件的绘图输出?避免绘图/步骤/ ...输出

我的意思是我在文件的开头放置一个函数(如clc),然后所有的绘图函数都被阻塞。

+0

不是我所知道的。但是你总是可以在'-nodisplay'模式下运行,而不用把GUI全部放在一起。 – angainor

回答

1

我不知道这样做的单个命令,但您可以使用一小段额外的代码来完成。

% Declare a variable for skipping at the top of your .m file 
skip = 1; %example, 1 = skip, 0 = plot 

% do things.... 

% Then nest your plot commands 
if (skip == 0) % wants to plot in this case 
    % Whatever plot code in here 
    plot(x,y); 
end 

这应该做的伎俩,虽然我意识到它不是一个干净,单一的功能,如你所要求的。我希望它有帮助! :)

此外,我明白,如果您不一定使用自己的.m文件,或脚本很长,这可能不实际。

0

你也可以在地块后面写close all,他们会被绘制出来,但会在瞬间关闭之后。它不干净,但工程。

1

你可以用你自己的(嵌套的函数内或在同一目录)重载内建绘图功能:当你打电话myfun,除非你改变当然plotting=false

function myfun(a,b) 
    plotting = false; 
    plot(a,b); 
    plot(b,a); 

    function varargout = plot(varargin) 
     if plotting 
      [varargout{1:nargout}] = builtin('plot',varargin{:}); 
     end 
    end 
end 

不会发生任何事情。

超载内置函数额外的信息:http://www.mathworks.nl/support/solutions/en/data/1-18T0R/index.html?product=ML&solution=1-18T0R

1

您可以所有 MATLAB地块隐形搭配:

set(0, 'DefaultFigureVisible', 'off'); 

更改offon相反的过程(这你可能需要要做,因为这会关掉全部你的地块!)

你可以将该行添加到您的m文件的开头,然后将

close all; 
set(0, 'DefaultFigureVisible', 'on'); 

加到最后。