MATLAB处理从 Python 返回的数据

目录

处理从 Python 返回的数据

Python 类型到 MATLAB 类型的自动映射

显式类型转换


处理从 Python 返回的数据

Python 类型到 MATLAB 类型的自动映射

        下表显示 MATLAB® 如何将从 Python® 返回的数据转换为 MATLAB 类型。

Python 返回类型,如 Python 中所显示

生成的 MATLAB 类型 - 标量

bool

logical

int(仅限版本 2.7)。对于 Python 版本 3.x int,您必须显式转换。

int64

float

double

complex

复数 double

所有其他 Python 类型 - type

Python 对象 - py.type

显式类型转换

        MATLAB 提供下列函数,用于手动将 Python 数据类型转换为 MATLAB 类型。

Python 返回类型或协议,如在 MATLAB 中所显示

MATLAB 转换函数

py.str(版本 2.7)

string
char
uint8

py.str(版本 3.x)

string
char

py.unicode

string
char

使用 __str__ 方法的对象

char

py.bytes

uint8

py.int

double

int64

py.long

double

int64

py.array.array[a]

numeric
double
single
int8
uint8
int16
uint16
int32
uint32
int64
uint64

序列协议;例如,py.list 和 py.tuple

cell

映射协议;例如,py.dict

struct

[a] You can convert py.array.array of any format to the MATLAB type you want.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值