如何在每次运行时使matlab编译python

时间:2017-10-30 16:03:20

标签: python matlab numpy

我有testPython.py:

import numpy as np
def numpyTest():
    print("Testing numpy...")
    x = np.array([1,2,3])
    return x

我有test.m:

clear; clc;

value = py.testPython.numpyTest()

当我运行test.m时,我得到:

测试numpy ......

value = 

  Python ndarray with properties:

           T: [1×1 py.numpy.ndarray]
        base: [1×1 py.NoneType]
      ctypes: [1×1 py.numpy.core._internal._ctypes]
        data: [1×24 py.buffer]
       dtype: [1×1 py.numpy.dtype]
       flags: [1×1 py.numpy.flagsobj]
        flat: [1×1 py.numpy.flatiter]
        imag: [1×1 py.numpy.ndarray]
    itemsize: 8
      nbytes: 24
        ndim: 1
        real: [1×1 py.numpy.ndarray]
       shape: [1×1 py.tuple]
        size: 3
     strides: [1×1 py.tuple]

    [1 2 3]

但是当我继续将代码更改为

import numpy as np
def numpyTest():
    print("Testing numpy...")
    x = np.array([4,5,6])
    return x

它仍然给我相同的输出[1,2,3]。如何让matlab为每次运行编译python代码?

0 个答案:

没有答案