MATLAB API
This block allows to create a co-simulation between VISION and MATLAB.

To be used, VISION toolbox for Matlab must be asked to AMCAD engineering team and folder path must be set up in VISION as shown below:


Inputs:
list of semi-colon separated input ports names, e.g.: input_ports=IN1;IN2;IN3
Outputs :
list of semi-colon separated output ports names, e.g.: output_ports=OUT1;OUT2
MATLAB startup directory :
path to MATLAB startup directory. The user should ideally set a startup.m in this directory to get all the necessary environment and path variables required to run all the modules during the circuit simulation.
API module
MATLAB function name calculating the module output. The name is a string xxx or xxx.yyy, where xxx should correspond to a script file xxx.m and yyy the name of the static class xxx method. Using static class allows for grouping several modules functions in a single script file xxx.m
Parameter list :
list of semi-colon separated optional model parameters values, e.g.:
params_list=F0;1e3;4
Note: parameters of the MATLAB API are not named; Users need to know the semantic of the parameters following their order in the list.
Model max wait time :
maximum time limit (minutes) beyond which the simulator considers that a MATLAB model is not responding and interrupt the simulation (default: 30min)

Buffered input :
When this option is activated, the input signals to the module are buffered for total signal frame length before the module function is called.
Configuration file 1:
Configuration file 2:
Optional data file names for use by the model. These can be used to instruct the model
With complicated parameters structure, applications like DPD learning may be used to backup model coefficients for subsequent reuse.

All matlab module in the circuit are linked to a single running matlab process called matlab server; it communicates with the simulator through inter-process pipe. An opened server can be used for multiple simulation sessions until it is explicitly closed. The tab allows for starting, stopping and closing matlab operations as below.
Start server:
Starts matlab server; when matlab server starts, it is automatically set in cosimulationmode with the simulator, i.e., it will be waiting for module runinstructions from the simulator. In that mode, matlab is locked, cannot edit files orexecute any instruction in command window. You can unlock matlab using “Stop cosimulation” button below.
Force restart:
Force starts matlab server when a running session is locked for some reason. You need then to manually kill any other running process, using task manager.
Stop simulation:
Stops co-simulation and unlocks matlab so that you can edit, update script files andrun any other matlab commands. When co-simulation is stopped, it will be necessaryto reset it from matlab command window using instruction server.start_cosim().
Close server:
Closes matlab server.
Optional data file names for use by the model. These can be used to instruct the model
A MATLAB module contains P-input ports and Q-output ports. The number of input ports can be zero. However, there must be a least one output port. The ports signals are considered complex numbers, i.e., if a real port signal is needed, it must be considered complex with a zero imaginary part. The module must implement an evaluation function with the following format.
function outputData=myMOduleName(inputData)
inputData and outputData are MATLAB structures defined as following:
inputData
inputData.nb_input_ports; % number of input ports
inputData.nb_output_ports; % number of output ports
inputData.nb_params; % number of model parameters
inputData.params; % vector of model parameters values (real numbers)
inputData.config_file1; % optional configuration file 1
inputData.config_file2; %optional configuration file 2
inputData.nb_samples; % number of time samples of input signals
inputData.start_time; % input signals start time value
inputData.sample_time; % input signals time step value
inputData.signals; % (nb_input_ports, nb_samples) matrix of input signals (complex
numbers)
outputData
outputData.signals; % (nb_output_ports, nb_samples) matrix of output signals
(complex numbers)
outputData.error_message; % error text in case error_flag=1
outputData.error_flag; % integer error flag (flag=1 if an error occurred, 0
otherwise)
For illustration, an example of simple module function representing a linear amplifier is :
function outputData=linearAMP(inputData)
nb_input=inputData.nb_input_ports;
nb_output=inputData.nb_output_ports;
nb_param=inputData.nb_params;
nb_sample=inputData.nb_samples;
G0=inputData.params(1);
Teta0=inputData.params(2);
Gain=G0*complex(sin(Teta0*2*pi/360),cos(Teta0*2*pi/360));
outputData.error_flag=0;
outputData.error_message='';
outputData.signals=zeros(nb_output,nb_sample);
for i=1:nb_output
for j=1:nb_sample
outputData.signals(i,j)=Gain*inputData.signals(i,j);
end
end
end