1. 修改变量上下限
npg = vv.N.Pg;
idpg =[vv.i1.Pg: vv.iN.Pg];
om = change_vars(om, 'Pg',npg, x0(idpg), xmin(idpg)+2, xmax(idpg));
[x0, xmin, xmax] = getv(om);
添加change_vars()函数
function om = change_vars(om, name, N, v0, vl, vu)
%ADD_VARS Adds a set of variables to the model.
% OM = ADD_VARS(OM, NAME, N, V0, VL, VU)
% OM = ADD_VARS(OM, NAME, N, V0, VL)
% OM = ADD_VARS(OM, NAME, N, V0)
% OM = ADD_VARS(OM, NAME, N)
%
% Adds a set of variables to the model, where N is the number of
% variables in the set, V0 is the initial value of those variables,
% and VL and VU are the lower and upper bounds on the variables.
% The defaults for the last three arguments, which are optional,
% are for all values to be initialized to zero (V0 = 0) and unbounded
% (VL = -Inf, VU = Inf).
%
% See also OPF_MODEL, GETV.
% MATPOWER
% $Id: add_vars.m,v 1.7 2010/04/26 19:45:25 ray Exp $
% by Ray Zimmerman, PSERC Cornell
% Copyright (c) 2008-2010 by Power System Engineering Research Center (PSERC)
%
% This file is part of MATPOWER.
% See http://www.pserc.cornell.edu/matpower/ for more info.
%
% MATPOWER is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published
% by the Free Software Foundation, either version 3 of the License,
% or (at your option) any