Octave和MATLAB非常相似,但处理Java略有不同。因此,可能有必要检测环境并使用适当的函数。以下函数可用于检测环境。因为存在持久性变量,它可以被重复调用,而不会受到严重的性能打击。
用例
%%
%% Return: true if the environment is Octave.
%%
function retval = isOctave
persistent cacheval; % speeds up repeated calls
if isempty (cacheval)
cacheval = (exist ("OCTAVE_VERSION", "builtin") > 0);
end
retval = cacheval;
end
版权所有 © 2024-2025 Octave中文网
ICP备案/许可证号:黑ICP备2024030411号-2