필터 지우기
필터 지우기

ValueError: only a scalar struct can be returned from MATLAB

조회 수: 34 (최근 30일)
Po-Hsuan Huang
Po-Hsuan Huang 2017년 9월 30일
댓글: Walter Roberson 2017년 9월 30일
I tried to use matlab.engine in python to import a struct from Matlab. my operation system is macOS Sierra, and the error message is :
File "/lib/python2.7/site-packages/matlab/engine/fevalfuture.py", line 82, in result
self._result = pythonengine.getFEvalResult(self._future,self._nargout, None, out=self._out, err=self._err)
ValueError: only a scalar struct can be returned from MATLAB
The values in the fields of the struct are cell, logical, single, unit8, and unit16. I am not sure what scalar struct refers to. Has anyone met the same problem before ?
Thanks!
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 9월 30일
A scalar struct is one for which size() of the struct itself says [1 1]. It does not matter what size the fields contained in the struct are, just the size of the struct itself. For example,
test1.this = 1:20;
test1.that = 'hello';
test2(1).this = 1;
test2(1).that = char('what','is','the','result','here?');
test3(1).this = 1:20;
test3(1).that = 'hello';
test3(2).this = 1;
test3(2).that = char('what','is','the','result','here?');
With these lines, size(test1) and size(test2) will both be [1 1] -- they are scalar structures, no matter how big the fields they hold are. Referring to test1.that would give you the single result 'hello' .
However, size(test3) will be [1 2]: it is not a scalar structure, it is a structure array. Referring to test3.that would give you a comma-separated list of two results, the first of which was 'hello' and the second of which was the char array, because of "structure expansion".

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by