User`s manual

Examples of Fortran MEX-Files
3-27
m_in = mxGetM(prhs(1))
n_in = mxGetN(prhs(1))
size = m_in * n_in
pr_in = mxGetPr(prhs(1))
C mxCreateFull dynamically allocates memory.
plhs(1) = mxCreateFull(m_in, n_in, 0)
pr_out = mxGetPr(plhs(1))
C Call the computational routine.
call compute(%val(pr_out), %val(pr_in), size)
return
end
C $Revision: 1.3 $
C===============================================================
C
C compute.f
C
C This subroutine doubles the input matrix. Your version of
C compute() may do whaveter you would like it to do.
C
C This is a MEX-file for MATLAB.
C Copyright (c) 1984-2000 The MathWorks, Inc.
C
C===============================================================
C Computational subroutine
subroutine compute(out_mat, in_mat, size)
integer size, i
real*8 out_mat(*), in_mat(*)
do 10 i=1,size
out_mat(i) = 2*in_mat(i)
10 continue
return
end