I am writing a Matlab mex-file. However, mex-files seem to have a serious limitation: help mexfilename
won't cause a help text to appear.
I could circumvent this by writing a m-file, that ultimately calls the mex-file, but includes help, but there has to be a better way.
On the other side, that way I could do all the error-checking in the m-file, where it is far more convenient to do so...
A MEX function behaves just like a MATLAB script or function. To call a MEX function, use the name of the MEX file, without the file extension. The MEX file contains only one function or subroutine. The calling syntax depends on the input and output arguments defined by the MEX function.
A MEX file is a function, created in MATLAB, that calls a C/C++ program or a Fortran subroutine. A MEX function behaves just like a MATLAB script or function. To experiment with calling MEX functions, use the code in Tables of MEX Function Source Code Examples to build and run examples.
I believe PierreBdR is right; you would create an m-file version of your function with just the header call and comment block, but no body.
It might not be a bad idea to put the error checking for the inputs in the m-file, then have the m-file invoke the mex-file (you may have to give them different names, though). It may be more straight-forward to check variables in MATLAB (using, for instance, built-ins like nargchk) and put them into a standard format that you may always want the inputs to the mex function to have. Many of the Image Processing Toolbox functions that I've looked at seem to do this (formatting and checking data in the m-file then doing the expensive computations in a mex-file).
You have to create an m-file (name.m) with the same name as your mex-file (name.c). Then, you put the function declaration and help text, but no function body. Example:
function [o1,o2] = MyFct(i1,i2,i3)
% MyFct takes 3 arguments and returns 2 ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With