Mi code is:
#include "fintrf.h"C======================================================================#if 0C C PruebaMex.FC .F file needs to be preprocessed to generate .for equivalentC #endifC C PruebaMex.fCC Computational functionC C======================================================================C Gateway routine subroutine mexFunction(nlhs, plhs, nrhs, prhs)C Declarations implicit none C mexFunction arguments: mwPointer plhs(*), prhs(*) integer nlhs, nrhsC Function declarations: mwPointer mxGetPr mwPointer mxCreateDoubleMatrix integer mxIsNumeric mwPointer mxGetM, mxGetNC Pointers to input/output mxArrays: mwPointer FS_ptr, DF_ptr, y1_ptrC Array information: mwPointer mrows, ncols mwSize sizeC Arguments for computational routine: real*8 FS_in, DF_in, y1_out(5) INTEGER NC-----------------------------------------------------------------------C Get the size of the input array. mrows = mxGetM(prhs(1)) ncols = mxGetN(prhs(1)) size = mrows*ncols N = 1C Create Fortran array and Scalar from the input argument. FS_ptr = mxGetPr(prhs(1)) DF_ptr = mxGetPr(prhs(2)) call mxCopyPtrToReal8(FS_ptr,FS_in,size) call mxCopyPtrToReal8(DF_ptr,DF_in,N)C Create matrix for the return argument. plhs(1) = mxCreateDoubleMatrix(mrows,ncols,0) y1_ptr = mxGetPr(plhs(1))C Call the computational subroutine. call PruebaMex(y1_out,FS_in,DF_in)C Load the data into y_ptr, which is the output to MATLAB. call mxCopyReal8ToPtr(y1_out,y1_ptr,size) C call mxFree(FS_ptr)C call mxFree(DF_ptr)C call mxFree(y1_ptr) RETURN ENDC-----------------------------------------------------------------------C Computational routine subroutine PruebaMex(y1_out,FS_in,DF_in) IMPLICIT none real*8 y1_out(*), FS_in(*), DF_in INTEGER I DO 503 I=1,5 y1_out(I) = FS_in(1) 503 CONTINUE RETURN END
I would appreciate it if someone could help me.
Thanks!!
Best Answer