1.在Matlab中调用python
step1.
命令行:res = py.numpy.zeros([5, 5])
报错:Python 错误 TypeError: 'float' object cannot be interpreted as an integer
原因:需要将[5,5]规定为整数
step2.
命令行:res=py.numpy.zeros(int([5, 5]))
或 res=py.numpy.zeros([int(5),int(5)])
报错:未定义与 'double' 类型的输入参数相对应的函数 'int'
原因:在MATLAB,求符号函数的定积分是使用int函数,造成冲突
改正:res = py.numpy.zeros(int32([5, 5]))
结果:
res = Python ndarray:
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
使用 details 函数查看 Python 对象的属性。
使用 double 函数转换为 MATLAB 数组。