REMOVE_USERFCN Removes a userfcn from the list to be called for a case. MPC = REMOVE_USERFCN(MPC, STAGE, FCN) A userfcn is a callback function that can be called automatically by MATPOWER at one of various stages in a simulation. This function removes the last instance of the userfcn for the given STAGE with the function handle specified by FCN. See also ADD_USERFCN, RUN_USERFCN, TOGGLE_RESERVES, TOGGLE_IFLIMS, RUNOPF_W_RES.
0001 function mpc = remove_userfcn(mpc, stage, fcn) 0002 %REMOVE_USERFCN Removes a userfcn from the list to be called for a case. 0003 % MPC = REMOVE_USERFCN(MPC, STAGE, FCN) 0004 % 0005 % A userfcn is a callback function that can be called automatically by 0006 % MATPOWER at one of various stages in a simulation. This function removes 0007 % the last instance of the userfcn for the given STAGE with the function 0008 % handle specified by FCN. 0009 % 0010 % See also ADD_USERFCN, RUN_USERFCN, TOGGLE_RESERVES, TOGGLE_IFLIMS, 0011 % RUNOPF_W_RES. 0012 0013 % MATPOWER 0014 % Copyright (c) 2009-2015 by Power System Engineering Research Center (PSERC) 0015 % by Ray Zimmerman, PSERC Cornell 0016 % 0017 % $Id: remove_userfcn.m 2644 2015-03-11 19:34:22Z ray $ 0018 % 0019 % This file is part of MATPOWER. 0020 % Covered by the 3-clause BSD License (see LICENSE file for details). 0021 % See http://www.pserc.cornell.edu/matpower/ for more info. 0022 0023 n = length(mpc.userfcn.(stage)); 0024 0025 if have_fcn('octave') 0026 fcn_info = functions(fcn); 0027 for k = n:-1:1 0028 cb_info = functions(mpc.userfcn.(stage)(k).fcn); 0029 if strcmp(cb_info.function, fcn_info.function) 0030 mpc.userfcn.(stage)(k) = []; 0031 break; 0032 end 0033 end 0034 else 0035 for k = n:-1:1 0036 if isequal(mpc.userfcn.(stage)(k).fcn, fcn) 0037 mpc.userfcn.(stage)(k) = []; 0038 break; 0039 end 0040 end 0041 end