MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   相当于MATLAB的单元格数组 (https://www.labfans.com/bbs/showthread.php?t=22922)

poster 2019-12-10 16:49

相当于MATLAB的单元格数组
 
我想在Numpy中创建类似MATLAB的单元格数组。我该怎么做?


回答:
Matlab单元格数组[URL="http://docs.scipy.org/doc/scipy/reference/tutorial/io.html#matlab-cell-arrays"]与[/URL] Python列表[URL="http://docs.scipy.org/doc/scipy/reference/tutorial/io.html#matlab-cell-arrays"]最相似[/URL] ,因为它们可以保存任何对象-但是scipy.io.loadmat会将它们导入为numpy对象数组-这是一个dtype = object的数组。

老实说,尽管您使用Python列表也很满意-如果您持有通用对象,您将失去numpy数组的几乎所有优点(numpy数组旨在保存一系列值,每个值占用相同的内存) 。



[url=https://stackoverflow.com/questions/1761419]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 10:28

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.