我正在编写一个Python脚本,在这个脚本中,我必须调用一些Matlab Psychtoolbox函数来打开一个屏幕窗口并显示一个点。我正在尝试使用Matlab引擎API for Python:运行代码时,我得到一个MatlabExecutionError:use:for the发动机屏幕('Preference','SkipSyncTests',1)行。我的代码如下:
import matlab.engine
import numpy as np
eng = matlab.engine.start_matlab()
screens = eng.Screen('Screens');
screenNumber =np.amax(screens);
eng.Screen('Preference', 'SkipSyncTests', 1)
[w,wrect]=eng.Screen('OpenWindow',0) ; # open PTB window
eng.Screen('FillOval',w,[1.0,1.0,1.0],[0,0]); # draw fixation dot (flip erases it)
eng.Screen('Flip',w); # draw image
eng.KbStrokeWait;
eng.Screen('CloseAll')
eng.quit()
错误为:
---------------------------------------------------------------------------
MatlabExecutionError Traceback (most recent call last)
<ipython-input-2-9907084f81ad> in <module>()
9
10
---> 11 q=eng.Screen('Preference', 'SkipSyncTests', 1) ; # do not test for accurate timing
12
13
~\AppData\Local\Programs\Python\Python36\lib\site-packages\matlab\engine\matlabengine.py in __call__(self, *args, **kwargs)
69 else:
70 return FutureResult(self._engine(), future, nargs, _stdout,
---> 71 _stderr, feval=True).result()
72
73 def __validate_engine(self):
~\AppData\Local\Programs\Python\Python36\lib\site-packages\matlab\engine\futureresult.py in result(self, timeout)
65 raise TypeError(pythonengine.getMessage('TimeoutCannotBeNegative'))
66
---> 67 return self.__future.result(timeout)
68
69 def cancel(self):
~\AppData\Local\Programs\Python\Python36\lib\site-packages\matlab\engine\fevalfuture.py in result(self, timeout)
80 raise TimeoutError(pythonengine.getMessage('MatlabFunctionTimeout'))
81
---> 82 self._result = pythonengine.getFEvalResult(self._future,self._nargout, None, out=self._out, err=self._err)
83 self._retrieved = True
84 return self._result
MatlabExecutionError: Usage:
oldPreferenceValue = Screen('Preference', preferenceName, [newPreferenceValue])
我希望在我的matlab应用程序中出现一个Psychtoolbox窗口,但是这个错误显示了。我还试着删除发动机屏幕('Preference','SkipSyncTests',1)行,但是相同类型的错误由[w,wrect]给出=发动机屏幕('OpenWindow',0)行。这是引擎API错误吗?或者我是不是用错误的语法为引擎API调用函数?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐