- Check whether the Struct objects you're passing from Java to Matlab have been properly initialized and populated with data.
- Simplify your code and test with a basic Struct object to isolate the issue. For example, create a Struct object with just one field and pass that to Matlab to see if it is recognized properly.
- Try using a different method of passing data between Java and Matlab, such as using a cell array instead of a struct array. This can sometimes help to avoid compatibility issues.
Java Matlab engine Struct array fields empty
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have an existing Java application using the matlab engine. The java program uses feval to pass an array of com.mathworks.matlab.types.Struct objects, a string, and a double to the running Matlab instance. This was working perfectly in the 2019b version of the matlab engine. I am required to start using the 2021b version of the engine.
Once I implemented the 2021b version of engine.jar, I started getting the com.mathworks.engine.MatlabException specifically telling me that all the struct fields were unrecogized.
After a bit of debugging in the Matlab workspace, and printing to console, I see that the size/dimensions of my struct array is being recognized, "structs = 1xN struct array with no fields". So the array structure is there, but all my data dissappears moving from Java to Matlab.
Has anyone seen this issue?
JAVA:
Struct[] data = createStructs();
double dval = 0.0;
String sval = "Some String";
engine.feval(1, "function", dval, data, sval);
0 comentarios
Respuestas (1)
Dhruv
el 21 de Abr. de 2023
The issue could be due to changes in the 2021b version of the Matlab engine, which may have affected the way that Struct objects are handled, try using the following approach:
Hopefully, one of these suggestions will help you resolve the issue. Please refer to the following documentation link for further guidance:
Ver también
Categorías
Más información sobre Call MATLAB from Java en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!