Follow the instructions under Generate a C++ MATLAB Data API Shared Library and Build a C++ Application, with these changes:
(1) In place of the file addmatrix.m in matlabroot\extern\examples\compilersdk\c_cpp\matrix, use the attached file subtractmatrix.m.
(2) If you want to test the function at the MATLAB Command Prompt, use this call:
[a, b, c] = subtractmatrix([19, 28, 37], [9, 8, 7])
rather than:
addmatrix([1 4 7; 2 5 8; 3 6 9], [1 4 7; 2 5 8; 3 6 9])
(3) Skip the step relating to creating a sample.
(4) Rather than copying and pasting the C++ driver code file generated in the samples folder, download the attached file subtractmatrix_mda.cpp.txt and change its name to subtractmatrix_mda.cpp.
(5) Use the call mbuild subtractmatrix_mda.cpp to compile and link the application.
When you run the application, you will see the same output generated at the MATLAB prompt by the MATLAB function subtractmatrix.m, followed by this output:
----------------------------------------------
Results retrieved via the MATLAB Data API:
Elements of mdaFinal:
10 20 30
Elements of mdaStruct[0]["elem1"]:
19 28 37
First element of mdaCellArray:
'Elements in astruct.elem1'
Second element of mdaCellArray:
3