String array from Matlab to Python

40 visualizaciones (últimos 30 días)
Anna Gossen
Anna Gossen el 16 de Ag. de 2021
Comentada: Leo el 4 de Mayo de 2023
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.

Respuesta aceptada

Yongjian Feng
Yongjian Feng el 16 de Ag. de 2021
Which version of matlab are you using? This is the doc of R2021a:
  3 comentarios
Newton Campbell
Newton Campbell el 5 de Sept. de 2022
Wait. So what was the solve for this? How did you construct the argument?
Leo
Leo el 4 de Mayo de 2023
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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Call Python from MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by