An error occurred when using matlab to call dll file which was generated by matlab coder
3 views (last 30 days)
- Hi, everyone! I am using matlab coder to convert m file to dll file using a simple test function. Now I've done the previous job, that is, dll file was generated.
- However, when using matlab functions(libstruct and calllib)to call the dll file ,an error message occurred: Cannot convert data value for field a due to error: A structure is required.
- The input argument of the function is a structure "in" with filed "a" and "b". And "a" is a variable-size argument(double inf*inf).
- When I change the argument "a" and "b" into a double 1*1 size, the error message disappeared. So I wonder if matlab doesn't support the variable-size argument in a dll file, and how can I solve the problem? (The structure is necessary in my algorithm!)
- Thank you in advance!
Ryan Livingston on 7 Apr 2016
When generating code for an Inf X Inf array, Coder will produce a C or C++ function which takes a struct argument to account for the fact that the array is variable size:
If you're intending to use the generated code in MATLAB then change the build target to a MEX file: