Borrar filtros
Borrar filtros

ValueError: only a scalar struct can be returned from MATLAB

34 visualizaciones (últimos 30 días)
Po-Hsuan Huang
Po-Hsuan Huang el 30 de Sept. de 2017
Comentada: Walter Roberson el 30 de Sept. de 2017
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 comentario
Walter Roberson
Walter Roberson el 30 de Sept. de 2017
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".

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by