GETVARNAME Get variable name by variable index (as in H matrix). [OUTPUT PARAMETERS] varName: comprise both variable type ('Va', 'Vm') and the bus number of the variable. For instance, Va8, Vm10, etc. created by Rui Bo on Jan 9, 2010
0001 function [varName] = getVarName(varIndex, pv, pq) 0002 %GETVARNAME Get variable name by variable index (as in H matrix). 0003 % [OUTPUT PARAMETERS] 0004 % varName: comprise both variable type ('Va', 'Vm') and the bus number of 0005 % the variable. For instance, Va8, Vm10, etc. 0006 % created by Rui Bo on Jan 9, 2010 0007 0008 % MATPOWER 0009 % $Id: getVarName.m,v 1.3 2010/04/26 19:45:26 ray Exp $ 0010 % by Rui Bo 0011 % Copyright (c) 2009-2010 by Rui Bo 0012 % 0013 % This file is part of MATPOWER. 0014 % See http://www.pserc.cornell.edu/matpower/ for more info. 0015 % 0016 % MATPOWER is free software: you can redistribute it and/or modify 0017 % it under the terms of the GNU General Public License as published 0018 % by the Free Software Foundation, either version 3 of the License, 0019 % or (at your option) any later version. 0020 % 0021 % MATPOWER is distributed in the hope that it will be useful, 0022 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0023 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0024 % GNU General Public License for more details. 0025 % 0026 % You should have received a copy of the GNU General Public License 0027 % along with MATPOWER. If not, see <http://www.gnu.org/licenses/>. 0028 % 0029 % Additional permission under GNU GPL version 3 section 7 0030 % 0031 % If you modify MATPOWER, or any covered work, to interface with 0032 % other modules (such as MATLAB code and MEX-files) available in a 0033 % MATLAB(R) or comparable environment containing parts covered 0034 % under other licensing terms, the licensors of MATPOWER grant 0035 % you additional permission to convey the resulting work. 0036 0037 %% get non reference buses 0038 nonref = [pv;pq]; 0039 0040 if varIndex <= length(nonref) 0041 varType = 'Va'; 0042 newIdx = varIndex; 0043 else 0044 varType = 'Vm'; 0045 newIdx = varIndex - length(nonref); 0046 end 0047 varName = sprintf('%s%d', varType, nonref(newIdx));