#include "fintrf.h"
!---------------------------------------------------------------------
subroutine mexFunction(nlhs, plhs, nrhs, prhs)
use MatlabAPImx
implicit none
!-ARG
mwPointer plhs(*), prhs(*)
integer*4 nlhs, nrhs
!-LOC
real(8), pointer :: xfit(:), yfit(:), xfite(:), yfite(:), yfit2(:)
integer imode, nptsf
real delfac
!-----
! insert some input argument checks here
xfit => fpGetPrCopy1(prhs(1))
yfit => fpGetPrCopy1(prhs(2))
xfite => fpGetPrCopy1(prhs(3))
yfite => fpGetPrCopy1(prhs(4))
imode = mxGetScalar(prhs(5))
yfit2 => fpGetPrCopy1(prhs(6))
nptsf = mxGetScalar(prhs(7))
delfac = mxGetScalar(prhs(8))
! check association status of xfit etc here
call crvfit(xfit,yfit,xfite,yfite,imode,yfit2,nptsf,delfac)
plhs(1) = mxArray(xfit(1:nptsf))
plhs(2) = mxArray(yfit(1:nptsf))
plhs(3) = mxArray(xfite(1:nptsf))
plhs(4) = mxArray(yfite(1:nptsf))
plhs(5) = mxArray(dble(imode))
plhs(6) = mxArray(yfit2(1:nptsf))
plhs(7) = mxArray(dble(nptsf))
plhs(8) = mxArray(dble(delfac))
call fpDeallocate(xfit)
call fpDeallocate(yfit)
call fpDeallocate(xfite)
call fpDeallocate(yfite)
call fpDeallocate(yfit2)
end subroutine mexFunction
subroutine crvfit(xfit,yfit,xfite,yfite,imode,yfit2,nptsf,delfac)
double precision xfit(*),yfit(*),xfite(*),yfite(*),yfit2(*)
integer imode
integer nptsf
real delfac
! etc
end subroutine
Best Answer