String array from Matlab to Python

9 ビュー (過去 30 日間)
Anna Gossen
Anna Gossen 2021 年 8 月 16 日
コメント済み: Leo 2023 年 5 月 4 日
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 件のコメント
Newton Campbell
Newton Campbell 2022 年 9 月 5 日
Wait. So what was the solve for this? How did you construct the argument?
Leo
Leo 2023 年 5 月 4 日
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 件)

カテゴリ

Help Center および File ExchangeCall 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