For PCElements only, gets/sets the index of a state variable turning it into the active state variable for the active circuit element. If the index exceeds the number of state variables or the active circuit element is not a PCelement this will trigger an error message. 


% Create DSS object

DSSObject = actxserver('OpenDSSEngine.DSS')

if ~DSSObject.Start(0),

                    disp('Unable to start openDSS');



DSSText = DSSObject.Text;

DSSCircuit = DSSObject.ActiveCircuit;

DSSLines = DSSCircuit.Lines;

% Compile a model        

DSSText.Command = 'Compile C:\myPath\myModel.dss';

DSSActiveElement = DSSCircuit.ActiveCktElement;

% Activates the generator located in this model


% gets the names of all the state variables of the active element

mySVNames = DSSActiveElement.AllVariableNames;

% requests for state variable Pshaft

Value = 1.23;

%Activates variable PShaft(4) by index

DSSActiveElement.VariableIdx = 4;

DSSActiveElement.VariableValue = Value;

mynewVal = DSSActiveElement.VariableValue;

myVarName = DSSActiveElement.VariableName;