Matlab connector (editor)

From COSSAN Wiki
Jump to: navigation, search
Split-arrows.svg It has been suggested that this article be split into entitled multiple articles: , , etc...

Matlab function and script can be connected to COSSAN-X using Evaluator -> Matlab file

Metadata

The name and description of the Matlab connector can be set or changed from what has been defined in the wizard wizard.

Mio metadata.png

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.

Mio input.png

Important.png 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.

Mio output.png

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:
Important.png Matlab function
Matlab with mcc compiler is needed to use Matlab functions.

Mio script.png

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

Imbox content.png Please improve this article by expanding it.
More details are required
a Matlab script using the COSSAN-X object directly. Please refer to the manual of the command line version of COSSAN-X. Mio type.png
Important.png Parameter values
The values of the parameters can be accessed only in the first position of the array of input (thus, in Tinput(1) ).
Important.png Matrix input
Only random variables can be used with the single array I/O.


See also

Matlab connector (wizard)