User`s manual
3 Creating Fortran MEX-Files
3-32
At the MATLAB prompt, entering
full = eye(5)
full =
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
creates a full, 5-by-5 identity matrix. Using fulltosparse on the full matrix
produces the corresponding sparse matrix.
spar = fulltosparse(full)
spar =
(1,1) 1
(2,2) 1
(3,3) 1
(4,4) 1
(5,5) 1
Calling Functions from Fortran MEX-Files
It’s possible to call MATLAB functions, operators, M-files, and even other
MEX-files from within your Fortran source code by using the API function
mexCallMATLAB. This example creates an mxArray, passes various pointers to a
subfunction to acquire data, and calls
mexCallMATLAB to calculate the sine
function and plot the results.
C $Revision: 1.8 $
C
================================================================
C
C sincall.f
C
C Example for illustrating how to use mexCallMATLAB.
C
C Creates an mxArray and passes its associated pointers (in
C this demo, only pointer to its real part, pointer to number
C of rows, pointer to number of columns) to subfunction fill()
C to get data filled up, then calls mexCallMATLAB to calculate
C sin function and plot the result.