I am compiling Matlab .m functions using Matlab compiler into libraries callable from C++. The particular function I am working with looks like this:
function status = cainit( model, varargin ) if nargin==1 % do something
elseif nargin==2 % do something else
endend
The C++ header file produced by Matlab compiler ("mcc") looks contains:
extern LIB_libca_CPP_API void MW_CALL_CONV cainit( int nargout, mwArray& status, const mwArray& model, const mwArray& varargin );
I want to call cainit from my C++ code such that the nargin==1 part of the Matlab function gets executed. But I can't figure out how to pass in "no arguments".
For example, if I try the most obvious:
mwArray status;cainit( 1, status, mwArray(""), mwArray() );
It still results in nargin==2 because mwArray() is an empty ([]) array.
Is there a way not to pass in an argument from C++? In other words, how do I do the C++ equivalent of Matlab "cainit('mymodel')"?
Thanks in advance!
Best Answer