how can i check if the file.mat is in use with another application ?
5 views (last 30 days)
Show older comments
i am using files called 'try_000.mat' and 'try_000.txt' to save some data, but before loading the files i want to check using matlab script if these files are in use with another software or not,
0 Comments
Answers (1)
Image Analyst
on 12 Jul 2014
Other than MATLAB, what other software would be using them?
I rarely find txt files locked but you can always try to open it with fopen() and if you get -1 then perhaps some other files has locked it, or you don't have permission to open it for some other reason.
2 Comments
Image Analyst
on 12 Jul 2014
You only open instantaneously to see if it's locked, then you close it immediately. Anyway, your other MATLAB process won't lock the text file, especially since it's not even opening it. The .mat file is opened just for a fraction of a second while it's pulling stuff out of it with the load() function.
See Also
Categories
Find more on Workspace Variables and MAT-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!