python list extension with scalars

1 vue (au cours des 30 derniers jours)
Ilya
Ilya le 30 Sep 2015
Commenté : Ilya le 1 Oct 2015
I need to export a few data from MATLAB to Python via the Python engine. It's needed to transform some 1xN vectors to python lists. The problem is that N can be also 1 (or >1). Then the code below won't work.
a_py = py.list(a)
Attempting to first initialize and then extend won't work as well.
a_py = py.list(); a_py.extend(a);
Is there any way to do this in an elegant way without writing if-else conditions?

Réponse acceptée

Robert Snoeberger
Robert Snoeberger le 30 Sep 2015
You could pass a cell array.
a_py = py.list(num2cell(a))
  1 commentaire
Ilya
Ilya le 1 Oct 2015
Yes, very good!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by