How do I print text to the MATLAB command window from a FORTRAN MEX file?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 14 Mai 2018
Réponse apportée : MathWorks Support Team
le 14 Mai 2018
How do I print text to the MATLAB command window from a FORTRAN MEX file?
Réponse acceptée
MathWorks Support Team
le 14 Mai 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Fortran with MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!