Make Matlab to read an US-ASCII file
4 views (last 30 days)
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?
Walter Roberson on 23 Sep 2012
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.