t_is.m

来自「以上所传的内容为电力系统比较全面的分析程序,才用的是matlab编写m的文件」· M 代码 · 共 37 行

M
37
字号
function t_is(got, expected, prec, msg)%T_IS  Tests if two matrices are identical to some tolerance.%   t_is(got, expected, prec, msg) increments the global test count%   and if the maximum difference between corresponding elements of%   got and expected is less than 10^(-prec) then it increments the%   passed tests count, otherwise increments the failed tests count.%   Prints 'ok' or 'not ok' followed by the msg, unless the global%   variable t_quiet is true. Intended to be called between calls to%   t_begin and t_end.%   MATPOWER%   $Id: t_is.m,v 1.3 2004/09/07 20:35:00 ray Exp $%   by Ray Zimmerman, PSERC Cornell%   Copyright (c) 2004 by Power System Engineering Research Center (PSERC)%   See http://www.pserc.cornell.edu/matpower/ for more info.if nargin < 4    msg = '';endif nargin < 3 | isempty(prec)    prec = 5;endgot_minus_expected = got - expected;max_diff = max(max(abs(got_minus_expected)));cond = ( max_diff < 10^(-prec) );t_ok(cond, msg);if ~cond    got    expected    got_minus_expected    fprintf('max diff = %g (allowed tol = %g)\n\n', max_diff, 10^(-prec));endreturn;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?