防止在octave脚本中打印输出,不在各处加分号?

问题描述 投票:0回答:1

Octave默认会打印每次赋值的结果,这在终端上相当有用,对于调试数据评估脚本相当有用。为了抑制它。

然而,在处理脚本时,这也是一个很大的烦恼,忘记了一个分号,由于那10000×10000矩阵的输出页数太多,GUI突然出现很大的滞后。

有没有一种方法可以代替抑制输出 默认如果明确的尾部有一个尾巴,那么就只能是赋值的呼应。, 是提供的吗?

octave
1个回答
2
投票

是的,Octave提供了 silent_functions.

默认情况下,它是false(即0)。

你可以将它设置为1,使函数保持沉默,也就是说,任何没有分号的函数值都不会被打印出来。

但是,请注意,当启用该功能时,您所描述的,即以逗号结束的函数也不会显示输出。要想在启用此功能的情况下有意显示函数的输出,您必须使用 disp 命令。

从文档中。

 -- silent_functions (NEW_VAL, "local")
 Query or set the internal variable that controls whether internal
 output from a function is suppressed.

 If this option is disabled, Octave will display the results
 produced by evaluating expressions within a function body that are
 not terminated with a semicolon.

 When called from inside a function with the "local" option, the
 variable is changed locally for the function and any subroutines it
 calls.  The original variable value is restored when exiting the
 function.

PS. 注意:这也适用于脚本,但要注意的是 为主控制台窗口。在实时控制台中,任何没有以分号结束的内容都会被打印出来,而不考虑这个设置。

© www.soinside.com 2019 - 2024. All rights reserved.