Cell array to python list

조회 수: 39 (최근 30일)
Fabio Ambrosini
Fabio Ambrosini 2022년 10월 10일
답변: Al Danial 2022년 10월 12일
I have a cell array 1x1000 in matlab where each element is a numeric matrix 77x77. I need these matrices on python so I would like to have them as a list of matrices but I don't know how to convert my cell array. any idea?

답변 (1개)

Al Danial
Al Danial 2022년 10월 12일
The easiest way is with mat2py.m: Here's an example:
>> a = { eye(2) eye(3) eye(2) }
a =
1x3 cell array
{2x2 double} {3x3 double} {2x2 double}
>> b = mat2py(a);
>> class(b)
'py.list'
>> b
Python list with values:
[array([[1., 0.],
[0., 1.]]),
array([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]]),
array([[1., 0.],
[0., 1.]])]

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by