Make Matlab to read an US-ASCII file
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I software that I use creates an US-ASCII log-text-file (but without extension) while it works.
Is there a way to read by Matlab that file in realtime (while the external software updates it) and then to load log-file and updates?
Thanks.
6 个评论
Walter Roberson
2012-9-23
Which operating system? And do you have the ability to alter the software that is generating the log file?
回答(1 个)
Walter Roberson
2012-9-23
The US-ASCII vs ISO 8859-1 and so on, is not going to be an appreciable problem for you.
Your problem is your operating system. The output file is going to be locked by MS Windows during the time the process has it open for writing, and unless you can take special precautions you are not going to be able to open it for reading until after it is closed.
I have not been able to find out what has to be done to allow reading of files as they are being written. MS Windows' normal IO functions do not document the fact that the locking will be done, making it difficult for me to track down how the locking is happening or how to turn it off.
The sort of locking that MS Windows is doing is known as "mandatory file locking", and it is not supposed to happen in POSIX compatible operating systems (which MS Windows XP SP2 and later claim to be) until you get to Trusted security level B1 or higher, which MS Windows definitely is not. (I'm not sure what level it is; I have seen claims that it is D4 but it might possibly have climbed to C2.) As it is not supposed to happen, the mechanisms to deal with it are not standardized.
Because of this locking difficulty, it is not useful for me to describe the mechanisms that would normally be used on POSIX-compatible operating systems that do not have this locking behavior.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!