How do I print text to the MATLAB command window from a FORTRAN MEX file?

4 visualizzazioni (ultimi 30 giorni)

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 14 Mag 2018
Use mexPrintf to print to the MATLAB command window when using MEX files. Two examples are shown below.
Example 1: Print "API says hello!" to the MATLAB command window
#include "fintrf.h"
subroutine mexFunction(nlhs, plhs, nrhs, prhs)
C Specify alert to be printed
character (len=*), PARAMETER :: txt = "API says hello!"
C Call the API
call mexPrintf(txt)
end
Example 2: Print the number of input arguments to the MATLAB command window:
#include "fintrf.h"
subroutine mexFunction(nlhs, plhs, nrhs, prhs)
character (len=1) :: c
character (len=50) :: txt
C Specify alert to be printed
write(txt,'(A)') 'Number of inputs (mexPrintf): '
C Convert nrhs to char
write(c,'(i1)') nrhs
C Call the API
call mexPrintf(txt)
call mexPrintf(c)
end
There are many FORTRAN MEX function source code examples available at:
Look in the table for examples with the .F file extension.

Più risposte (0)

Categorie

Scopri di più su Fortran with MATLAB in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by