如何称呼;“Python的MATLAB引擎”;在Django?

如何称呼;“Python的MATLAB引擎”;在Django?,python,django,matlab,matlab-engine,Python,Django,Matlab,Matlab Engine,我已经从MathWork安装了“MatlabEngineforPython”。我的python版本是3.4,如果我将自己编写的m.file和.py文件放在同一个文件夹下,效果会很好 但当我想在Django使用引擎时,一切都出了问题。.m函数称为“doa.m”。我的项目结构如下: my views.py是: import os .... from django.shortcuts import render import matlab.engine .... def result(request

我已经从MathWork安装了“MatlabEngineforPython”。我的python版本是3.4,如果我将自己编写的m.file和.py文件放在同一个文件夹下,效果会很好

但当我想在Django使用引擎时,一切都出了问题。.m函数称为“doa.m”。我的项目结构如下:

my views.py是:

import os
....
from django.shortcuts import render
import matlab.engine
....
def result(request):
    eng = matlab.engine.start_matlab()
    eng.doa(nargout=0)
    return render(request, 'result.html')
我的URL.py是:

url( r'result/$', views.result, name='result'),
但是,当我进入时,错误是: 未定义的函数或变量“doa”。 Trceback是:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/result/

Django Version: 1.9.2
Python Version: 3.4.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'photos',
 'jfu']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "J:\Program Files\Python34\lib\site-packages\django\core\handlers\base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "J:\Program Files\Python34\lib\site-packages\django\core\handlers\base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "I:\Eclipse_Workspace\demo\photos\views.py" in result
  60.     eng.doa(nargout=0)

File "J:\Program Files\Python34\lib\site-packages\matlab\engine\matlabengine.py" in __call__
  84.                                 _stderr).result()

File "J:\Program Files\Python34\lib\site-packages\matlab\engine\futureresult.py" in result
  106.                 self._future,self._nargout, None, out=self._out, err=self._err)

Exception Type: MatlabExecutionError at /result/
Exception Value: Undefined function or variable 'doa'.

谁能给我解释一下吗?谢谢

例如,对于Matlab 2015b,在“主页”选项卡下,单击“设置路径”,然后单击“添加文件夹”并添加Django项目所在的文件夹路径。

是否可以尝试调用一些内置命令,而不是您自己的文件?可能
eng.plus(1,2,nargout=1)
?您是否将自己的m文件添加到matlab中的搜索路径?看起来引擎正常,但matlab找不到您的文件。@Daniel您好,我尝试了b=eng.max(100200),结果很好。请检查以下内容: