EditState

EditState()

Description

Edits a state in an existing state matrix.

Syntax

NewMatrix = EditState(ExistingMatrix, StateName, ParameterName, ParameterValue)

Parameters

  • ExistingMatrix: The state matrix you are editing.

  • StateName: A character string specifying the name of the state you are editing.

  • ParameterName: A character string specifying the parameter you are editing. Valid values are:

    • 'Timer'

    • 'StateChangeConditions'

    • 'OutputActions'

  • ParameterValue: The new value of the parameter.

    • For timer, this is the new timer duration in seconds.

    • For StateChangeConditions, this is a cell array of strings formatted with pair-wise arguments as in AddState.

    • For OutputActions, this is a cell array of strings formatted with pair-wise arguments as in AddState.

Returns

  • A state matrix struct, updated with the new parameter.

Example

% This code generates a simple state matrix that drives BNC output channel 1 to 5V (high) for 1 second before exiting.

% Next, EditState is used to make the state high for 10 seconds instead of 1.

% Finally, EditState is used to make the matrix end immediately if BNC input channel 1 receives a trigger pulse during the 10 second state.

sma = NewStateMatrix();

sma = AddState(sma, 'Name', 'MyState', ...

'Timer', 1,...

'StateChangeConditions', {'Tup', 'exit'},...

'OutputActions', {'BNCState', 1});

sma = EditState(sma, 'MyState', 'Timer', 10);

sma = EditState(sma, 'MyState', 'StateChangeConditions', {'Tup', 'exit', 'BNC1High', 'exit');