Matlab connector (editor)
Matlab function and script can be connected to COSSAN-X using Evaluator -> Matlab file
Contents
Metadata
The name and description of the Matlab connector can be set or changed from what has been defined in the wizard wizard.
Input
Define which inputs, i.e. random variable, parameter or function, will be used in the Matlab script or function. Inputs created in the input editor can be added [+] or removed [-], and their order can be changed.
Priority ordering The function must be ordered so that the random variables, parameters and functions called are preceding them in the list. |
Output
The name of the output quantities returned by the Matlab script/function must be added in this list [+]. Such names can also be deleted [-] and reordered.
Script tab
The following script type are available:
- Matlab script: a Matlab (a batch sequence of Matlab commands). Structure and single array I/O can be used with a script
- Matlab function: a Matlab function. Function can be used with all the I/O types.
- User defined analysis:
This editor tab is used to write the Matlab script/function used by the Matlab connector. An auto-competition is available, invoked with the shortcut CTRL+SPACE.
Matlab I/O type
A combination of Matlab script type and Matlab input/output type must be defined. Not all the input/output types are available for all the script types.
Matlab Script
Structure
Input values are accessed from the fields of an array of (Matlab) structures [1]. The structure array must be named Tinput. The output values are saved into the field of the array of structures named Toutput. The field names are the name of the input and output quantities as defined in Input and Output metadata of the Mio (insert link).
Single array
Input values are stored in a Matlab array called Minput. Output values should be stored in the matrix called Moutput.
The Minput matrix is structured such that each row contains different samples and the column number the inputs as ordered in the Input lists. The Moutput matrix is structured such that each row contains different samples and the column number the output as ordered in the Input lists.
Matlab Function
Structure
Input values are accessed from the fields of an array of (Matlab) structures [2]. The output values are saved into the field of the array of structures. There are no restrictions of the name of such structures. The field names of these structures are defined by the name of the inputs and outputs of the Matlab connector.
Single array
Input values are stored in a Matlab array. Output values are stored in the matrix called. There are no restrictions of the name of such matrices.
function [output] = myfun(input)
The matrices are structured such that each row contains different samples and the column number the inputs and output as ordered in the Input/Output lists, respectively.
For more information about Matlab function: [3]
Multiple Array
- Multiple arrays: NOTE to EP: I have never used it and I don't know how it works. Can you write the description?
function [out1, out2, ...] = myfun(in1, in2, ...)
Each input and output declared in the Input/Output lists are passed as a separate input and output argument, respectively.
For more information about Matlab function: [4]
User defined analysis
a Matlab script using the COSSAN-X object directly. Please refer to the manual of the command line version of COSSAN-X. Parameter values The values of the parameters can be accessed only in the first position of the array of input (thus, in Tinput(1) ). |