Matlab integration
In order to be able to configure the Matlab block, you need to first set up the following Matlab® integration:
Ensure that the system requirements are met for the Matlab Development Environment, CSense Development Environment, and CSense Runtime Environment.
Create a Matlab function script that meets the Function_Requirements_and_Limitations for scripts that can be used with the CSense Matlab block.
Use the Matlab Compiler with the added Compiler SDK to produce a 32-bit Windows .NET assembly that can be executed using the Matlab Compiler Runtime (MCR). Consult the Matlab documentation for information on the MCR.
Place a copy of your compiled Matlab .NET assembly in the CSense Matlab Repository on ALL systems where you intend to execute your CSense block.
System Requirements
Matlab Development Environment
The following Matlab components are required on the development system where the Matlab module is prepared:
Matlab 8.4.0.150421 (R2014b) 32 bit
Matlab Compiler SDK for Matlab 8.4.0.150421 (R2014b) 32 bit
Matlab Compiler 5.2 32 bit
CSense Development Environment
The following Matlab components are required on the development system where the CSense blueprint is prepared:
Matlab Compiler Runtime (MCR) 8.4
The Matlab user module compiled to a 32-bit .NET assembly using the Matlab Compiler SDK
CSense Runtime Environment
The following Matlab components are required on the runtime system where the CSense Action Object executes:
Matlab Compiler Runtime (MCR) 8.4 for Windows 32-bit
The Matlab user module compiled to a 32-bit .NET assembly using the Matlab Compiler SDK
Backwards Compatibility
The CSense Matlab block is not automatically compatible with future or previous versions of the Matlab MCR. Supporting versions of the MCR other than the stated MCR version contained in this guide will require new releases of the CSense Matlab block.
Note : If the Matlab MCR is not installed, it is not possible to open the Matlab block property page. If you attempt to open the property page when the Matlab MCR is not installed, a message is displayed in the Architect messages pane indicating that the "MWArray" file cannot be opened.
Function Requirements and Limitations
The CSense Matlab block makes use of user-specified functions. These functions must satisfy the following requirements:
Inputs and Outputs
All supported functions must take in at least one input array (either Numeric or String).
All supported functions must return a single output array (either Numeric or String).
Single Array Return Only
The CSense Matlab block supports only those Matlab functions that return a single array. Functions that return multiple arrays are not supported.
One-Dimensional Arrays Only
Input and output arrays must be one-dimensional. They can be 1 x n or n x 1 vectors. Output arrays of strings must be nx1 vectors.
Multi-dimensional arrays are not supported.
Working With String Array Output
If your function returns an array of strings, you must do the following:
Use the char() function to specify the string array. This returns the string array as a column vector.
Do not transpose the string array.
Use a comma as the array element delimiter.
For example, your return array of strings might look like the following:
x = char('A','BB','CCC')
No Support for Tilde Operator on Function Inputs
Matlab functions making use of the tilde (~) operator for function inputs are not supported.
No Class Support
Although Matlab allows users to define classes in scripts, no support for classes or class methods is provided in the CSense Matlab block.
In the following example, a simple Matlab class is defined and compiled:
classdef hello
methods
function greet(this)
disp('Hello!')
end
end
end
When compiled using the Matlab Compiler, the above class and its methods are not exposed in the CSense Matlab block. If, however, the class usage is wrapped in a Matlab function, the function can be exposed and made available for use in the CSense Matlab block.
No Graphics and Graphical User Interface Support
Matlab functions that produce any form of graphical user interface or other graphical elements such as plots are not supported.
In the following example, the plot method may cause an error when executed from the CSense Matlab block:
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y)
CSense Matlab Repository
The CSense Matlab block provides users with the option to select a compiled Matlab .NET assembly from the CSense Matlab repository. Only compiled Matlab .NET assemblies located in the CSense Matlab repository are available for selection and use from the CSense Matlab block.
The CSense Matlab Repository is located on all machines that have CSense installed on them and resides at the following location:
<C:\ProgramData\Proficy CSense\Matlab Repository>
Related topics: