在Python中使用Matlab用户函数会产生错误

在Python中使用Matlab用户函数会产生错误,matlab,python-3.6,matlab-engine,Matlab,Python 3.6,Matlab Engine,我有用户Matlab函数。这是别人写的。该文件中有多个函数,但与.m文件itsel同名的第一个函数是我尝试调用的函数。它得到4个参数(字符串、字符串、字符串、布尔值)。 通常在Matlab中我这样称呼它:函数('string','string,true) 在Python中尝试时,我使用以下代码 def CodeGenerationAndResim(self, Models=None, Resim=False, Type='TW'): """ This function will star

我有用户Matlab函数。这是别人写的。该文件中有多个函数,但与.m文件itsel同名的第一个函数是我尝试调用的函数。它得到4个参数(字符串、字符串、字符串、布尔值)。 通常在Matlab中我这样称呼它:函数('string','string,true) 在Python中尝试时,我使用以下代码

def CodeGenerationAndResim(self, Models=None, Resim=False, Type='TW'):
    """ This function will start Matlab and generates code for each Simulink model
        and creates Resim archives for the release.
        All variables:
            Models                      - All Sim Modelto generate c code for
            Resim                       - Running Resim function
            Type                        - Type of Resim archive
            matlabEngine                - Matlab engine to start Matlab
            MatlabEngineSuccessfull     - Checks if Matlab engine is started without error
            CodeGenSuccessfull          - Checks if Code Generation is successsful
            ResimSuccessfull            - Checks if Resim function is performed successfully.
    """


    # Check variables
    MatlabEngineSuccessfull = True
    CodeGenSuccessfull = True
    ResimSuccessfull = True


    # Call Matlab engine
    try:
        matlabEngine = matlab.engine.start_matlab('-nodesktop', background = False)
        matlabEngine.addpath("C:\\temp")
    except EngineError as e:
        MatlabEngineSuccessfull = False
        Print("Could not start Matlab. Do you have Matlab 64 bits installed?")

    # Generate code for models in a loop
    if Models is not None and MatlabEngineSuccessfull:
        for model in Models:
            try:
                matlabEngine.rtwbuild(model)
            except Exception as e:
                CodeGenSuccessfull = False
                print('Something went wrong')

    # Running Resim
    if Resim and MatlabEngineSuccessfull and CodeGenSuccessfull:
        try:
            matlabEngine.resimPrepareNewVersion('all','DAS2_TwYYWW_2005',1)
        except Exception as e:
            ResimSuccessfull = False
            print(e)


    return MatlabEngineSuccessfull, CodeGenSuccessfull, ResimSuccessfull
我得到的错误如下:

Error using resimPrepareNewVersion
Too many output arguments.
Too many output arguments.

我不明白这个错误。我已经给出了与Matlab中相同的参数。即使我给它3,2,或者没有参数,我也会得到同样的错误。当Matlab加载时,这些函数会自动加载,所以我不需要添加路径,但我用了任何方法。然而,我没有给出任何途径就尝试了。代码生成和启动Matlab没有任何问题。在Matlab中,此函数加载一些其他文件并打开一个信息对话框,它意味着任何东西。

真奇怪,我一直将错误标记为
输入参数太多,而不是
输出参数

我通过插入
nargout=0
解决了这个问题

编辑:

matlabEngine.resimPrepareNewVersion('all','DAS2_TwYYWW_2005',1)
致:

而且效果很好。谢谢

matlabEngine.resimPrepareNewVersion('all','DAS2_TwYYWW_2005',1, nargout=0)