How do I call a MATLAB Compiler 4.4 (2006a) generated shared library function that has variable number of input arguments from my C++ application?

7 views (last 30 days)
I would like to call a MATLAB Compiler 4.4 (2006a) generated shared library function that uses VARARGIN to handle a variable number of input arguments from my C++ application.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 28 Jan 2010
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:
!vararg_example.exe
Alternatively, the EXE can be executed from the DOS prompt in the current directory:
vararg_example.exe
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
mwArray input;

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2006a

Community Treasure Hunt

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

Start Hunting!