mlSetVariable (Function) In french: mlEcritVariable Writes the value of a variable for the MATLAB session.
gnSessionID is int gnSessionID = mlInitialize() IF gnSessionID = -1 THEN Error(ErrorInfo(errFullDetails)) END // Code of BTN_Create_Variables button aParameter is array of 1 real = [4] aResult is array of 1 by 1 real = [[123]] IF NOT mlSetVariable(gnSessionID, "i", aParameter) THEN Error("Failure writing the variable") RETURN END sCodeToRun is string = "myRoot = sqrt(i)" EDT_Result = mlExecute(gnSessionID, sCodeToRun) aResult = mlGetVariable(gnSessionID, "myRoot") IF ErrorOccurred THEN Trace("Error: " + ErrorInfo()) END Trace("Root = " + aResult[1,1]) Trace("List of variables before deletion: " + mlListVariable(gnSessionID)) mlDeleteVariable(gnSessionID, "i") mlDeleteVariable(gnSessionID, "myRoot") Trace("List of variables after deletion: " + mlListVariable(gnSessionID))
Syntax
<Result> = mlSetVariable(<Session identifier> , <Variable name> , <Value>)
<Result>: Boolean - True if the variable was modified,
- False otherwise. If an error occurs, the ErrorOccurred variable is set to True. To get the details of the error, use ErrorInfo with the errMessage constant.
<Session identifier>: Integer Identifier of MATLAB session. This identifier is returned by mlInitialize. <Variable name>: Character string Name of the variable to write. <Value>: Array of integers, reals, ... Value of variable. Remarks Supported types The supported types are: - signed and unsigned integers on 1, 2, 4 and 8,
- reals on 4 and 8,
- booleans,
- characters.
This page is also available for…
|
|
|
|