是否可以从 Octave 中的另一个脚本中调用一个脚本?

Is it possible to call a script from within another script in Octave?

PHP 具有漂亮的 include() 功能,可以将外部文件引入主脚本。这在 Octave 中可能吗?我尝试使用 load() 但我一直收到错误消息:error: load: unable to determine the file format of 't_whse.m' 这让我觉得这是错误的方法,或者在 Octave 中实际上是不可能的。

您不需要调用 load,因为 load 保留用于从文件加载数据。相反,您只想按名称调用脚本。这将(如果它实际上是一个脚本)执行脚本并使调用脚本可以访问该脚本中定义的任何变量。

script1.m

disp('Beginning of script1');
script2;
fprintf('Value = %d\n', value)
disp('End of script1')

script2.m

disp('Beginning of script2');
value = 2;
disp('End of script 2');