MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Bedienungsanleitung Seite 128

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 408
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 127
3 Creating Fortran MEX-Files
3-18
integer x_pr, y_pr
C--------------------------------------------------------------
C
integer nlhs, nrhs
integer mxGetM, mxGetN, mxIsNumeric
integer m, n, size
real*8 x(1000), y(1000)
C Check for proper number of arguments.
if(nrhs .ne. 1) then
call mexErrMsgTxt('One input required.')
elseif(nlhs .ne. 1) then
call mexErrMsgTxt('One output required.')
endif
C Get the size of the input array.
m = mxGetM(prhs(1))
n = mxGetN(prhs(1))
size = m*n
C Column * row should be smaller than 1000.
if(size.gt.1000) then
call mexErrMsgTxt('Row * column must be <= 1000.')
endif
C Check to ensure the array is numeric (not strings).
if(mxIsNumeric(prhs(1)) .eq. 0) then
call mexErrMsgTxt('Input must be a numeric array.')
endif
C Create matrix for the return argument.
plhs(1) = mxCreateFull(m, n, 0)
x_pr = mxGetPr(prhs(1))
y_pr = mxGetPr(plhs(1))
call mxCopyPtrToReal8(x_pr, x, size)
C Call the computational subroutine.
call matsq(y, x, m, n)
Seitenansicht 127
1 2 ... 123 124 125 126 127 128 129 130 131 132 133 ... 407 408

Kommentare zu diesen Handbüchern

Keine Kommentare