TestAutomationPythonModulesReference
TestAutomationPythonModulesReference
If possible, always provide the serial number of the hardware, the relevant dSPACE License
ID, or the serial number of the CmContainer in your support request.
Important Notice
This publication contains proprietary information that is protected by copyright. All rights
are reserved. The publication may be printed for personal or internal use provided all the
proprietary markings are retained on all printed copies. In all other cases, the publication
must not be copied, photocopied, reproduced, translated, or reduced to any electronic
medium or machine-readable form, in whole or in part, without the prior written consent
of dSPACE GmbH.
This publication and the contents hereof are subject to change without notice.
Contents
Safety Precautions 7
General Warning............................................................................................. 7
CellArray................................................................................................................ 17
CellArray Class Description............................................................................ 17
GetDimensions.............................................................................................. 19
GetItem............................................................................................ ............ 19
GetNumberOfDimensions................................................................. ............ 20
SetItem......................................................................................................... 21
Matfile................................................................................................................... 23
Matfile Class Description............................................................................... 23
Close................................................................................................ ............ 24
DeleteArray................................................................................................... 25
GetArray....................................................................................................... 26
GetDir........................................................................................................... 27
Load................................................................................................. ............ 27
Open................................................................................................ ............ 28
PutArray........................................................................................................ 30
PutArrayAsGlobal.......................................................................................... 30
Whos............................................................................................................ 31
Matlab................................................................................................................... 33
Matlab Class Description............................................................................... 33
Close................................................................................................ ............ 35
ConnectedMATLABInstallations..................................................................... 36
ExecutablePath.............................................................................................. 37
Execute......................................................................................................... 37
3
May 2024 Test Automation Python Modules Reference
Contents
GetArray....................................................................................................... 38
GetOutputs................................................................................................... 39
IsAlive........................................................................................................... 40
IsMUMatlabOpen.......................................................................................... 41
Open................................................................................................ ............ 41
ProcessArchitecture....................................................................................... 43
ProcessID....................................................................................................... 43
PutArray........................................................................................................ 44
Version.......................................................................................................... 45
WatchdogMethod......................................................................................... 45
Examples (matlablib2)............................................................................................. 47
Examples of Using matlablib2........................................................................ 47
Index 53
4
Test Automation Python Modules Reference May 2024
About this Reference
Content This reference provides detailed information on the Python commands of the Test
Automation Python Modules.
It is assumed that you know the Test Automation Python Modules Guide .
Symbol Description
Indicates a hazardous situation that, if not avoided,
V DANGER
will result in death or serious injury.
Indicates a hazardous situation that, if not avoided,
V WARNING could result in death or serious injury.
Indicates a hazardous situation that, if not avoided,
V CAUTION could result in minor or moderate injury.
Indicates a hazard that, if not avoided, could result in
NOTICE
property damage.
Indicates important information that you should take
Note
into account to avoid malfunctions.
Indicates tips that can make your work easier.
Tip
Indicates a link that refers to a definition in the
glossary, which you can find at the end of the
document unless stated otherwise.
Follows the document title in a link that refers to
another document.
Naming conventions dSPACE user documentation uses the following naming conventions:
5
May 2024 Test Automation Python Modules Reference
About this Reference
Special Windows folders Windows‑based software products use the following special folders:
Accessing dSPACE Help and After you install and decrypt Windows‑based dSPACE software, the
PDF files documentation for the installed products is available in dSPACE Help and as PDF
files.
dSPACE Help (local) You can open your local installation of dSPACE Help:
§ On its home page via Windows Start Menu
§ On specific content using context-sensitive help via F1
PDF files You can access PDF files via the icon in dSPACE Help. The PDF
opens on the first page.
6
Test Automation Python Modules Reference May 2024
Safety Precautions
Safety Precautions
Introduction To avoid risk of injury and/or property damage, read and ensure compliance with
the safety precautions given.
General Warning
Danger potential Using dSPACE software can be dangerous. You must observe the following
safety instructions and the relevant instructions in the user documentation.
7
May 2024 Test Automation Python Modules Reference
Safety Precautions
Data loss during operating The shutdown procedure of Microsoft Windows operating systems causes some
system shutdown required processes to be aborted although they are still being used by dSPACE
software. To avoid data loss, the dSPACE software must be terminated manually
before a PC shutdown is performed.
8
Test Automation Python Modules Reference May 2024
Overview of the Python Modules for Test Automation
Introduction The Test Automation Python Modules include specific Python modules used for
automating tests.
Overview The illustration gives an overview of the modules and classes provided by the Test
Automation Python Modules.
Module Description
matlablib2 To exchange data between MATLAB and the Python Interpreter,
invoke MATLAB functions or to access files in the MATLAB file
format. See Interfacing MATLAB (matlablib2) on page 11.
Packaging and licences For more information on packages and licences, refer to Introduction to
the Python Modules for Test Automation (Test Automation Python Modules
Guide ).
9
May 2024 Test Automation Python Modules Reference
Overview of the Python Modules for Test Automation
Quick reference For the Test Automation Python Modules, an introduction is available. The object
information is summarized in a set of compact tables, each of which provides
a quick overview of the available objects, object dependencies, attributes and
methods. For a printable version of the quick reference, refer to dSPACE Help.
Multiple identifiers In the Test Automation Python Modules, some method and class identifiers are
multiply used. For easier access to the related documentation in dSPACE Help,
see Multiple Use of Identifiers Within the Test Automation Python Modules on
page 49.
10
Test Automation Python Modules Reference May 2024
Interfacing MATLAB (matlablib2)
CellArray................................................................................................. 17
Matfile.................................................................................................... 23
Matlab.................................................................................................... 33
Examples (matlablib2).............................................................................. 47
11
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Introduction The matlablib2 module provides access to MATLAB. Using the class Matlab,
you can exchange data between MATLAB and the Python Interpreter or
invoke MATLAB functions (use existing m-scripts, for example). matlablib2 also
provides access to the MATLAB file format (MAT files) via the class Matfile. For
information on how to use matlablib2, refer to Working with MATLAB (Test
Automation Python Modules Guide ).
Purpose Refer to
(CaptureData class)1)
CellArray class
To provide a Python representation of CellArray on page 17
the MATLAB cell array type.
Matfile class
To create an instance of the class Matfile. Matfile on page 23
Matlab class
To create an instance of the class Matlab. Matlab on page 33
1) Discontinued as of dSPACE Release 2021‑A.
Exception matlablibError
12
Test Automation Python Modules Reference May 2024
Overview of the matlablib2 Module
Constants The following table shows the constants and their description:
Constant Description
CellArrayType The type of a CellArray instance
MATLAB type conversion MATLAB’s array classes are mapped to the Python types int, long, float, string,
complex, list (of lists), dictionary and CellArray instances when reading from a
MAT file or the MATLAB Workspace. Vice versa these Python types are mapped
to MATLAB array classes when writing to a MAT file or the MATLAB Workspace.
The following table shows some examples of type conversions that apply to both
directions:
13
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
The following table shows the exact type conversion rules for MATLAB basic
types while reading from a MAT file or the MATLAB Workspace:
14
Test Automation Python Modules Reference May 2024
Overview of the matlablib2 Module
The following table shows the exact type conversion rules for Python basic types
while writing to a MAT file or the MATLAB Workspace:
15
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
The following examples show how to specifiy row or column vectors, matrices
and cell arrays in Python:
In MATLAB all arrays are at least two-dimensional. As one can see from the
examples and Interfacing MATLAB (matlablib2), it is possible to put plain values
to MATLAB via PutArray() as an abbreviation for specifying a list containing a list
that contains a single value (see example 1x1 vector above). The same approach
applies to row vectors: one can simply specify a Python list containing the values
as an abbreviation for a list containing a single list containing the column values
(see example 1x3 row vector above).
16
Test Automation Python Modules Reference May 2024
CellArray
CellArray
Where to go from here Information in this section
GetDimensions........................................................................................ 19
GetItem................................................................................................... 19
GetNumberOfDimensions........................................................................ 20
SetItem.................................................................................................... 21
Module matlablib2
or
OBJ = matlablib2.CellArray([N1 [,N2 [,N3]]])
Description The Python representation of a MATLAB cell array is an instance of the class
CellArray, defined in module matlablib2. The constructor of CellArray may be
used in one of two ways:
§ The first form takes a list as argument, containing the number of elements
for each dimension of the resulting CellArray instance. The length of the list
determines the dimension of the CellArray. Due to limitations in MATLAB,
the dimension is at least 2. Therefore, if the constructor argument is [], the
resulting CellArray has size 0x0, if the argument is [N1], the resulting CellArray
has size N1x0. if the argument is [N1, N2], the resulting CellArray has size
N1xN2, and so on.
§ As a abbreviation, the second form takes up to three arguments of type int. If
no argument is given, an instance of an empty cell array is created (dimension
17
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Exception Description
matlablibError On any error of this method, matlablibError is returned.
Attributes –
Method Purpose
GetDimensions To get the size of each dimension. See
GetDimensions on page 19.
GetItem To get a cell array item. See GetItem on page 19.
GetNumberOfDimensions To get the number of dimensions. See
GetNumberOfDimensions on page 20.
SetItem To set a cell array item. See SetItem on page 21.
18
Test Automation Python Modules Reference May 2024
CellArray
GetDimensions
Class CellArray
Description This method returns a list containing the sizes for each dimension.
Parameters –
Type Description
List A list containing the size of each dimension. The length of the list is at
least 2.
Exception Description
matlablibError On any error of this method, matlablibError is returned.
GetItem
Class CellArray
19
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Description The content of the cell at the indices specified by IndexList is returned.
Type Description
Various The Python representation of the cell array. See Interfacing MATLAB
(matlablib2) on page 11 for a detailed description of valid Python
value types.
Exception Description
matlablibError On any error of this method, matlablibError is returned.
GetNumberOfDimensions
Class CellArray
20
Test Automation Python Modules Reference May 2024
CellArray
Description This method returns the number of dimensions of the CellArray instance. Due to
MATLAB’s representation of arrays, this number is at least 2.
Parameters –
Type Description
Int The number of dimensions
Exception Description
matlablibError On any error of this method, matlablibError is returned.
SetItem
Class CellArray
Description The content of the cell at the indices specified by IndexList is set.
21
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Return value –
Exception Description
matlablibError On any error of this method, matlablibError is returned.
Related methods –
22
Test Automation Python Modules Reference May 2024
Matfile
Matfile
Where to go from here Information in this section
Close....................................................................................................... 24
DeleteArray............................................................................................. 25
GetArray................................................................................................. 26
GetDir..................................................................................................... 27
Load........................................................................................................ 27
Open....................................................................................................... 28
PutArray.................................................................................................. 30
PutArrayAsGlobal.................................................................................... 30
Whos...................................................................................................... 31
Module matlablib2
Description An instance of the class Matfile can be used to access MAT files. While reading a
MAT file, MATLAB’s array classes are converted to Python types. While writing a
MAT file, certain Python types are converted to MATLAB arrays.
23
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Parameters –
Exception Description
matlablibError On any error of this method, matlablibError is returned.
Attributes –
Method Purpose
Close To close a MAT file. See Close on page 24.
DeleteArray To delete an array from a MAT file. See DeleteArray on
page 25.
GetArray To get an array from a MAT file. See GetArray on page 26.
GetDir To get the directory of a MAT file. See GetDir on page 27.
Load To load the whole MAT file and assign all contained arrays
to variables in the global namespace with the same names.
See Load on page 27.
Open To open a MAT file. See Open on page 28.
PutArray To put an array represented as Python object to a MAT file.
See PutArray on page 30.
PutArrayAsGlobal To put an array represented as Python object to a MAT file
as global. See PutArrayAsGlobal on page 30.
Whos To list variables in the MAT file in long form. See Whos on
page 31.
Close
Class Matfile
Syntax OBJ.Close()
24
Test Automation Python Modules Reference May 2024
Matfile
Parameters –
Return value –
Exception Description
matlablibError The file could not be closed.
Open on page 28
DeleteArray
Class Matfile
Syntax OBJ.DeleteArray(NameOfArray)
Description This method deletes the array with the specified name from the MAT file.
Return value –
25
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Exception Description
matlablibError On any error of this method, matlablibError is returned.
GetArray
Class Matfile
Description This method gets the array with the specified name from the MAT file and
returns its Python representation.
Type Description
Various The Python representation of the MATLAB-array. See Interfacing
MATLAB (matlablib2) on page 11 for a detailed description of valid
Python value types.
Exception Description
matlablibError On any error of this method, matlablibError is returned.
26
Test Automation Python Modules Reference May 2024
Matfile
GetDir
Class Matfile
Description This method gets the directory of a MAT file and returns a list of name strings of
all of the arrays contained in the file.
Parameters –
Type Description
List A list of array name strings
Exception Description
matlablibError On any error of this method, matlablibError is returned.
Load
Class Matfile
Syntax OBJ.Load()
Purpose To load the whole MAT file and assign all contained arrays to variables in the
global namespace with the same names.
27
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Description This method loads each array contained in the MAT file. Each array is assigned
to a variable with the same name in the top-level script environment (the global
namespace). This method is similar to MATLAB’s load command.
Note
Existing variables with the same name are overwritten without notice. Be
sure not to overwrite variables that are needed for the currently running
script.
Parameters –
Return value –
Exception Description
matlablibError On any error of this method, matlablibError is returned.
Open on page 28
Open
Class Matfile
Description This method allows you to open MAT files for reading and writing.
28
Test Automation Python Modules Reference May 2024
Matfile
The following table shows all possible values for the Mode parameter:
Mode Description
String
"r" Opens the file for reading only; determines the current version of the MAT file by inspecting the files
and preserves the current version.
"u" Opens the file for update, both reading and writing, but does not create the file if the file does
not exist (equivalent to the "r+"-mode of fopen); determines the current version of the MAT file by
inspecting the files and preserves the current version.
"w" Opens the file for writing only; deletes previous contents, if any.
"w4" Creates a MAT file that is compatible with MATLAB version 4 and earlier.
"wL" Opens the file for writing character data using the default character set for your system. The resulting
MAT file can be read with MATLAB version 6 or 6.5. If you do not use the wL mode switch, MATLAB
writes character data to the MAT file using Unicode encoding by default.
"wz" Opens the file for writing compressed data. The same compression ratio is applied than by saving
workspace variables to a MAT file.
"w7.3" Creates a MAT file in an HDF5‑based data format. This file format can store objects that require more
than 2 GB. This is the default file format that can be read with MATLAB version 7.3 and later.
Return value –
Exception Description
matlablibError The file could not be opened.
Load on page 27
29
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
PutArray
Class Matfile
Description This method puts the array with the specified name and value, represented as
Python object, to the MAT file.
Return value –
Exception Description
matlablibError On any error of this method, matlablibError is returned.
PutArrayAsGlobal
Class Matfile
30
Test Automation Python Modules Reference May 2024
Matfile
Description This method puts the array with the specified name and value, represented
as Python object, to the MAT file. It is similar to PutArray(), except the array
is loaded by MATLAB into the global workspace and a reference to it is
set in the local workspace. If you write to a MATLAB 4 format MAT file,
PutArrayAsGlobal does not load it as global, and acts the same as PutArray.
Return value –
Exception Description
matlablibError On any error of this method, matlablibError is returned.
Whos
Class Matfile
Description This method lists all the variables in the MAT file, together with information
about their size, bytes, class, etc., and returns this information as a string. The
31
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
method’s behavior is very similar to MATLAB’s command whos, except for the
summary line. Unfortunately, due to lacks of the MATLAB MAT file API, the size
of struct arrays can only be determinated as a rough approximation of the real
value.
Note
For variables of any class except struct arrays, only the header information is
loaded into the memory; struct arrays are loaded completely, and therefore
memory consumption may be vast depending on the size of the struct
arrays contained in the file.
Parameters –
Type Description
String A string containing all variable names, dimensions, size and class
information
Exception Description
matlablibError On any error of this method, matlablibError is returned.
32
Test Automation Python Modules Reference May 2024
Matlab
Matlab
Where to go from here Information in this section
Close....................................................................................................... 35
ConnectedMATLABInstallations............................................................... 36
ExecutablePath........................................................................................ 37
Execute................................................................................................... 37
GetArray................................................................................................. 38
GetOutputs............................................................................................. 39
IsAlive...................................................................................................... 40
IsMUMatlabOpen.................................................................................... 41
Open....................................................................................................... 41
ProcessArchitecture................................................................................. 43
ProcessID................................................................................................. 43
PutArray.................................................................................................. 44
Version.................................................................................................... 45
WatchdogMethod................................................................................... 45
Module matlablib2
33
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Description An instance of the class Matlab can be used to transport MATLAB arrays from
MATLAB to Python and vice versa, and to execute MATLAB commands. Outputs
of the MATLAB workspace can be read by Python applications. The MATLAB
Command Window can be minimized and restored.
Parameters –
Exception Description
matlablibError On any error of this method, matlablibError is returned.
34
Test Automation Python Modules Reference May 2024
Matlab
Method Purpose
Close To end the connection to MATLAB and quit the MATLAB application.
See Close on page 35.
Execute To execute a MATLAB command.
See Execute on page 37.
GetArray To get a Python representation of a MATLAB array from a MATLAB workspace
variable.
See GetArray on page 38.
GetOutputs To return the output of the last OBJ.Execute() command that ordinarily appears in
the MATLAB Command Window.
See GetOutputs on page 39.
IsAlive To test if MATLAB is alive.
See IsAlive on page 40.
(RestoreCommandWindow) Discontinued as of dSPACE Release 2021‑A.
(MaximizeCommandWindow) Discontinued as of dSPACE Release 2021‑A.
(MinimizeCommandWindow) Discontinued as of dSPACE Release 2021‑A.
Open To open the connection to MATLAB.
See Open on page 41.
PutArray To assign an array or string to a MATLAB workspace variable.
See PutArray on page 44.
Close
Class Matlab
Purpose To end the connection to MATLAB and quit the MATLAB application.
35
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Return value –
Exception Description
matlablibError The underlying COM call fails or if MATLAB is not accessible.
Open on page 41
ConnectedMATLABInstallations
Class Matlab
Purpose To get a list of the connected MATLAB installations containing the installation
paths and whether they are configured as the preferred MATLAB instance.
Type Description
List of Each tuple consists of two values:
tuples § String: Installation path of the connected MATLAB instance, e.g.,
C:\Program Files\MATLAB\R2016a
§ Int: Shows whether the MATLAB installation is configured as the
preferred MATLAB instance during installation or afterwards by
using the dSPACE Installation Manager.
§ 0: MATLAB installation is not preferred.
§ 1: MATLAB installation is preferred.
Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.
36
Test Automation Python Modules Reference May 2024
Matlab
ExecutablePath
Class Matlab
Purpose To get the path to the executable of the connected MATLAB instance.
Type Description
String Path to the executable of the connected MATLAB instance: e.g.,
C:\Program Files\MATLAB\R2016a\bin\MATLAB.exe.
Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.
Version on page 45
Execute
Class Matlab
Syntax OBJ.Execute(Command)
37
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Return value –
Exception Description
matlablibError § The underlying COM call fails.
§ MATLAB is not accessible.
§ The MATLAB command fails for some reason. In that case
the exception contains MATLAB’s error message as string.
GetArray
Class Matlab
38
Test Automation Python Modules Reference May 2024
Matlab
Type Description
Various A Python representation of a MATLAB array on success. See
Interfacing MATLAB (matlablib2) on page 11 for a detailed list
of supported MATLAB array classes and their conversion to an
appropriate Python representation.
None on error.
Exception Description
matlablibError § The underlying COM call fails.
§ MATLAB is not accessible.
GetOutputs
Class Matlab
Purpose To return the output of the last Execute command that ordinarily appears in the
MATLAB Command Window.
Parameters –
39
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Type Description
String Output of the last Execute command
Exception Description
matlablibError § The underlying COM call fails
§ MATLAB is not accessible.
IsAlive
Class Matlab
Description IsAlive() sends an "alive" message to MATLAB and tests if access to MATLAB still
is possible.
Parameters –
Type Description
Boolean A value different from 0 on success ("alive"), 0 on error ("dead").
Exception –
Open on page 41
40
Test Automation Python Modules Reference May 2024
Matlab
IsMUMatlabOpen
Class Matlab
Purpose To get the flag of whether the connected MATLAB instance is opened for
multiple use.
Type Description
Tuple § Int: If set to 1, the connected MATLAB instance is enabled for
(Int, multiple use.
String, § String: Path to the executable of the connected MATLAB instance:
String) e.g., C:\Program Files\MATLAB\R2016a\bin\MATLAB.exe.
§ String: Version of the connected MATLAB instance: e.g., R2016a.
Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.
Version on page 45
Open
Class Matlab
41
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Return value –
Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.
IsAlive on page 40
42
Test Automation Python Modules Reference May 2024
Matlab
ProcessArchitecture
Class Matlab
Type Description
Int § Constants.PROC_ARCHITECTURE_32BIT:
32-bit MATLAB instance
§ Constants.PROC_ARCHITECTURE_64BIT:
64-bit MATLAB instance
Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.
ProcessID
Class Matlab
Type Description
Int Process ID of the connected MATLAB instance.
43
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.
PutArray
Class Matlab
Description PutArray assigns an Array to a MATLAB workspace variable. The name of the
variable is given by ArrayName. The second parameter specifies the Array (or
Matrix) to be assigned to the variable. In Python, lists are used to represent a
MATLAB array. See Interfacing MATLAB (matlablib2) on page 11 for the tables of
type conversion rules.
Return value –
Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.
44
Test Automation Python Modules Reference May 2024
Matlab
Version
Class Matlab
Type Description
String Version of the connected MATLAB instance: e.g., R2016a.
Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.
IsMUMatlabOpen on page 41
WatchdogMethod
Class Matlab
or
[GetValue =] OBJ.WatchdogMethod
Purpose To set or get whether MATLAB restarts if the watchdog timer is exceeded.
45
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
Type Description
Integer § Constants.WATCHDOG_PREVENT: MATLAB is prevented from being
closed.
§ Constants.WATCHDOG_RESTART: MATLAB will be restarted if
necessary.
Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.
Related attributes –
46
Test Automation Python Modules Reference May 2024
Examples (matlablib2)
Examples (matlablib2)
Overview of the demo scripts If you have installed dSPACE Python Extensions,
you will find the following example scripts in:
<dSPACEPythonExtensions_InstallationFolder>\Demos\Python Test
Automation\Interfacing Matlab (matlablib2):
§ ExecutingCommands\d_ExecuteMatlabCommands.py
This script creates arrays in MATLAB whose contents are plotted using the
MATLAB plot command. Also, the observation of MATLAB results from Python
is demonstrated.
§ ExchangeOfSimpleDatatypes\d_SimpleDataTypes.py
This script generates arrays of different types and sizes, puts them to
MATLAB's workspace and reads them out again. It concentrates on the more
simple datatypes in MATLAB. Use the whos command in MATLAB to observe
the results.
§ ExchangeOfComplexDatatypes\d_ComplexDataTypes.py
This script generates arrays of different types and sizes, puts them to
MATLAB's workspace and reads them out again. It concentrates on the more
complex datatypes CellArray and StructArray.
§ ReadingAndWritingMatfiles\d_ReadAndWriteMatFiles.py
This script demonstrates how to read data from and write data to MAT files. It
creates a MAT file which is then read again to copy the contents into another
MAT file. Finally, two identical MAT files exist.
To start the demo scripts, use an external Python interpreter, for example,
PythonWin. You find it in Python 3.9 - PythonWin in the Windows Start menu.
Before you start a script, read its description for further information.
Tip
You can run the demo script also in AutomationDesk by using an ExecFile
block.
47
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)
48
Test Automation Python Modules Reference May 2024
Multiple Use of Identifiers Within the Test Automation Python Modules
Multiply used identifiers In the Test Automation Python Modules, some method and class identifiers
are multiply used. This does not mean that the identifiers are ambiguous. The
identifiers are unique, because each object must be fully qualified.
The table below gives an overview of the identifiers that are multiply used in the
Test Automation Python Modules.
Close....................................................................................................... 50
GetArray................................................................................................. 50
Open....................................................................................................... 50
PutArray.................................................................................................. 51
49
May 2024 Test Automation Python Modules Reference
Multiple Use of Identifiers Within the Test Automation Python Modules
Close
GetArray
Open
50
Test Automation Python Modules Reference May 2024
PutArray
PutArray
51
May 2024 Test Automation Python Modules Reference
Multiple Use of Identifiers Within the Test Automation Python Modules
52
Test Automation Python Modules Reference May 2024
Index
Index
GetArray 26
C GetDir 27
Load 27
CellArray
Open 28
matlablib2 17
PutArray 30
CellArray class
PutArrayAsGlobal 30
GetDimensions 19
Whos 31
GetItem 19
Matlab
GetNumberOfDimensions 20
matlablib2 33
SetItem 21
Matlab class
Close
Close 35
Matfile class 24
ConnectedMATLABInstallations 36
Matlab class 35
ExecutablePath 37
Common Program Data folder 6
Execute 37
ConnectedMATLABInstallations
GetArray 38
Matlab class 36
GetOutputs 39
IsAlive 40
D IsMUMatlabOpen 41
DeleteArray ProcessArchitecture 43
Matfile class 25 ProcessID 43
Documents folder 6 PutArray 44
Version 45
WatchdogMethod 45
E
matlablib2 11
ExecutablePath example 47
Matlab class 37 Matfile 23
Execute Matlab 33
Matlab class 37
O
G
Open
GetArray Matfile class 28
Matfile class 26 Open (Matlab)
Matlab class 38 matlablib 41
GetDimensions
CellArray class 19
P
GetDir
Matfile class 27 ProcessArchitecture
GetItem Matlab class 43
CellArray class 19 ProcessID
GetNumberOfDimensions Matlab class 43
CellArray class 20 PutArray
GetOutputs Matfile class 30
Matlab class 39 Matlab class 44
PutArrayAsGlobal
Matfile class 30
I
IsAlive
S
Matlab class 40
IsMUMatlabOpen SetItem
Matlab class 41 CellArray class 21
L V
Load Version
Matfile class 27 Matlab class 45
Local Program Data folder 6
W
M WatchdogMethod
Matfile Matlab class 45
matlablib2 23 Whos
Matfile class Matfile class 31
Close 24
DeleteArray 25
53
May 2024 Test Automation Python Modules Reference
Index
54
Test Automation Python Modules Reference May 2024