How do I print text to the MATLAB command window from a FORTRAN MEX file?
4 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2018-5-14
回答: MathWorks Support Team
2018-5-14
How do I print text to the MATLAB command window from a FORTRAN MEX file?
采纳的回答
MathWorks Support Team
2018-5-14
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fortran with MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!