MATLAB interface to C library: defineargument() doesn't define the 'length' argument if already mentioned as part of the pointer argument
1 次查看(过去 30 天)
显示 更早的评论
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'.
- 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.
1 个评论
Stefanie Schwarz
2023-11-28
@Jerome Almon Moderator comment: Removed the MATLAB license number from the post.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!