Using python inside MATLAB: unexpected results when printing Python list inside MATLAB

2 views (last 30 days)
I would like to print the python list inside MATLAB. However, instead of printing the first element of the list, it prints the '(', that is, it considers the list as a string and prints the first character of that string which is '('.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 30 Aug 2021
Edited: MathWorks Support Team on 30 Aug 2021
The MATLAB automatically converts compatible Python data to MATLAB data. For Python types that do not have compatible MATLAB types, MATLAB provides functions to convert Python data types to MATLAB types manually. 
For Python types that do not have compatible MATLAB types, such as list in this case, use the MATLAB functions shown in the Explicit Type Conversion table. This table also describes how to convert strings and certain numeric types explicitly.
Please refer to the below links for your reference which gives more information about Python types that do not have compatible MATLAB types:
Please use 'cell' (refer to the below link) MATLAB conversion to convert list into a MATLAB compatible data types.

More Answers (0)

Products


Release

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!