MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Manual do Utilizador Página 123

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 408
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 122
Examples of Fortran MEX-Files
3-13
Below is the gateway routine that calls the computational routine.
C The gateway routine
subroutine mexFunction(nlhs, plhs, nrhs, prhs)
integer nlhs, nrhs
C--------------------------------------------------------------
C (pointer) Replace integer by integer*8 on the DEC Alpha
C platform.
C
integer plhs(*), prhs(*)
integer mxCreateString, mxGetString
C--------------------------------------------------------------
C
integer mxGetM, mxGetN, mxIsString
integer status, strlen
character*100 input_buf, output_buf
C Check for proper number of arguments.
if (nrhs .ne. 1) then
call mexErrMsgTxt('One input required.')
elseif (nlhs .gt. 1) then
call mexErrMsgTxt('Too many output arguments.')
C The input must be a string.
elseif(mxIsString(prhs(1)) .ne. 1) then
call mexErrMsgTxt('Input must be a string.')
C The input must be a row vector.
elseif (mxGetM(prhs(1)) .ne. 1) then
call mexErrMsgTxt('Input must be a row vector.')
endif
C Get the length of the input string.
strlen = mxGetM(prhs(1))*mxGetN(prhs(1))
C Get the string contents (dereference the input integer).
status = mxGetString(prhs(1), input_buf, 100)
C Check if mxGetString is successful.
if (status .ne. 0) then
call mexErrMsgTxt('String length must be less than 100.')
endif
Vista de página 122
1 2 ... 118 119 120 121 122 123 124 125 126 127 128 ... 407 408

Comentários a estes Manuais

Sem comentários