Clear Filters
Clear Filters

MATLAB interface to C library: defineargument() doesn't define the 'length' argument if already mentioned as part of the pointer argument

1 view (last 30 days)
Hello,
MATLAB Version: 9.13.0.2049777 (R2022b)
Operating System: Microsoft Windows 10 Enterprise Version 10.0 (Build 19045)
I am trying to call C function (in a shared object) from MATLAB following the documentation in 'MATLAB interface to C library'.
  1. I am able to generate the interface dll file successfully. For the function "void mean(float32_t *v, uint32_t len);", I modified the SHAPE parameter for the argument 'v' to 'len' as instructed in the documentation.
defineArgument(meanDefinition, "v", "clib.array.library.Float", "input", "len", "Description", "[in] v Pointer to input array"); % <MLTYPE> can be "clib.array.library.Float", or "single"
defineArgument(meanDefinition, "len", "uint32", "Description", "[in] len Number of elements in array");
After this, I built the interface file and it's successful as well. However, when I call the function from matlab like this, clib.library.mean(buffer, size), it throws an error as incorrect number of arguments. So when I print the summary of the interface file, I notice that the type of second argument 'len' is missing/not defined.
=> clib.library.mean(clib.array.library.Float)
But when I don't specify the SHAPE parameter of 'v' argument as 'len' but just as 1 (for the sake of debugging),
defineArgument(meanDefinition, "v", "clib.array.library.Float", "input", 1, "Description", "[in] v Pointer to input array"); % <MLTYPE> can be "clib.array.library", or "single"
and build it, the summary has the second argument defined.
=> clib.library.mean(clib.array.library.Float,uint32)
2. Also the argument “v” is supposed to be of direction “inputoutput”. Because the list of values it points to are modified by the function. So when I change to it, it throws the following error,
Error using clibgen.FunctionDefinition/defineArgument
Invalid direction specified for argument 'v'. Expected direction is 'input'
Thanks,
Jerome.

Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!