String array from Matlab to Python

Hello,
I need to pass a number of arguments to python function in Matlab. One of them is a string array like {'red', 'green'}.
I am creating a python list with py.list({'red', 'green'}) and insert the result as an argument into the python function.
The error message that I get is:
'Conversion of MATLAB 'string' array to Python is not supported.'
How to do this correctly?
Thank you
Anna
P.S. The issue is solved. No problem with creating and passing lists, it was just a weird string in argument.

 采纳的回答

Yongjian Feng
Yongjian Feng 2021-8-16
Which version of matlab are you using? This is the doc of R2021a:

3 个评论

Hi,
I am using 2020a. But the reason was that the argument was built in a weird way. So, the issue is solved. Sorry, I just couldn't find the question to close it.
Thanks
Wait. So what was the solve for this? How did you construct the argument?
I had the same error in R2022b.
Solved it by changing string array to cell array with strings.
>>> x = ["bob", "cat"] does not work.
Conversion of MATLAB 'string' array to Python is not supported.
>>> x = {"bob", "cat"} works

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Call Python from MATLAB 的更多信息

产品

版本

R2020a

标签

Community Treasure Hunt

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

Start Hunting!

Translated by