A PUZZLING QUESTION: Does Matlab's Mex file support external inputs and outputs?
Show older comments
Hi, I would like to ask if Mex (Fortran) files are able to use Fortran's OPEN/CLOSE/WRITE/READ from files command?
If yes, how do I implement it in Matlab's Mex files? Else, are there any alternatives to output in an external document?
Thanks
Zhonghao
Answers (1)
James Tursa
on 9 Jun 2014
2 votes
Yes, you can use native Fortran file I/O in mex routines. Just write the code as you normally would. The main restriction is in screen I/O ... you can't READ(5,etc) or WRITE(6,etc) in a mex routine as the operations will not work properly. But file I/O is OK.
5 Comments
Zhong Hao
on 10 Jun 2014
James Tursa
on 10 Jun 2014
What do you mean by "can't seem to write"? Get unexpected value printed to the file? Get an error trying to write to the file? MATLAB crashes? Or what?
Zhong Hao
on 11 Jun 2014
James Tursa
on 11 Jun 2014
Edited: James Tursa
on 11 Jun 2014
Yes, but what is the specific message you see on the screen? Anything? Does anything show up in the Test.txt file?
Zhong Hao
on 11 Jun 2014
Categories
Find more on Fortran Source MEX Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!