Your main problem is that you need to create the output array PLHS(1) before you access it. Also your NLHS and NRHS types are wrong. Try this:
#include <fintrf.h>
C
C Gateway routine
C
SUBROUTINE MEXFUNCTION(NLHS, PLHS, NRHS, PRHS)
implicit none
C mexFunction arguments:
MWPOINTER PLHS(*), PRHS(*)
INTEGER NLHS, NRHS
mwPointer, external :: mxGetPr, mxGetPi
mwPointer, external :: mxCreateDoubleMatrix, mxCreateNumericArray
mwSize, external :: mxGetM, mxGetN
MWPOINTER YPP
mwSize M, N
integer*4 ComplexFlag
REAL *8 RYPP(1)
RYPP(1) = 10
M = 1
N = 1
ComplexFlag = 0
PLHS(1) = mxCreateDoubleMatrix( M, N, ComplexFlag )
YPP = MXGETPR(PLHS(1))
CALL MXCOPYREAL8TOPTR(RYPP, YPP, M*N)
RETURN
END
Best Answer