MATLAB: How to use the static methods ‘fromBean’ and ‘fromMap’ of the MWStructArray class defined for MATLAB Builder JA (R2008a)

codeexampleMATLAB Compiler SDK

The MATLAB Builder JA (R2008a) documentation mentions methods 'fromBean' and 'fromMap' for MWStructArray class but does not provide examples on how to use them.

Best Answer

The attached files “SampleBean.java” and “MapAndBeanToMWStruct.java” illustrate how to use MWStructArray.fromBean and MWStructArray.fromMap methods.
“SampleBean.java” is a sample Java bean class. “MapAndBeanToMWStruct.java” shows how to use the 'fromBean' and 'fromMap' methods.
NOTE: For the 'fromBean' method, the user should ignore the field class with the value 0 in the MWStructArray. This shows up because of the inherited getClass() method of all classes.