How do I print text to the MATLAB command window from a FORTRAN MEX file?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 14 de Mayo de 2018
Respondida: MathWorks Support Team
el 14 de Mayo de 2018
How do I print text to the MATLAB command window from a FORTRAN MEX file?
Respuesta aceptada
MathWorks Support Team
el 14 de Mayo de 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.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Fortran with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!