The attached example files demonstrate calling a C++ shared library function which uses VARARGIN and VARARGOUT.
To execute the example code, perform the following steps:
1. Download the files vararg_example.cpp and makeplot.m to your current directory.
2. At the MATLAB prompt, compile the MATLAB file makeplot.m into a C++ shared library with the command:
mcc -B cpplib:libplot makeplot.m
3. Compile the C++ program with the command:
mbuild vararg_example.cpp libplot.lib
4. Execute the resulting EXE file from the MATLAB prompt:
Alternatively, the EXE can be executed from the DOS prompt in the current directory:
The following modifications on "vararg_example.cpp" can be done to pass fewer arguments to the MAKEPLOT library function:
1. For passing no input arguments to MAKEPLOT, replace the following block of code:
mwArray input(1, 2, mxCELL_CLASS);
// Assign values to cell array "input":
mwArray range(1, 2, mxDOUBLE_CLASS);
range(1,1) = 5;
range(1,2) = 10; // Range of data to be plotted.
mwArray title("Random numbers between 5 and 10"); // Plot title
input.Get(1,1).Set(range);
input.Get(1,2).Set(title);
with
Best Answer