在Matlab中为每个局部函数导入函数 [英] Import functions in Matlab for every local function
本文介绍了在Matlab中为每个局部函数导入函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个m-file
,其中有一些定义为局部函数的测试.它们是从主要功能调用的:
I have an m-file
with a couple of tests defined as local functions. They are called from the main function:
function tests = main_function_test()
tests = functiontests(localfunctions);
end
我在做具有一定容忍度的断言,所以我需要导入每个局部函数:
I am doing assertions with some tolerance, so I need to import in each local function:
import matlab.unittest.constraints.IsEqualTo;
import matlab.unittest.constraints.AbsoluteTolerance;
为了进行以下形式的断言:
in order to make assertions of the form:
verifyThat(testCase, actual, IsEqualTo(expected, ...
'Within', AbsoluteTolerance(0.00001)));
是否可以只导入一次这些函数,以便可以在每个本地函数中重用它们?
Is it possible to import those functions just once so they can be reused in each local function?
推荐答案
查看全文