MATLAB Answers

Previously accessible file is now inaccessible

8 views (last 30 days)
Hans Sunaryanto
Hans Sunaryanto on 18 Sep 2019
Edited: per isakson on 19 Sep 2019
Hi all,
I'm trying to create a code that goes through a few thousand .txt files and extract information from each one to compile to an excel sheet. The first run using the code is always successful and outputs the file I want to see, however any subsequent runs would cause it to throw the error listed above. I've found the only way to get around this is to close out the entire matlab application and restart it again, which isn't very practical. Does anyone have a solution for this?
Thanks in advance!


Sign in to comment.

Accepted Answer

per isakson
per isakson on 18 Sep 2019
Edited: per isakson on 19 Sep 2019
You need to close the file after reading, add
fclose( fileID )
filedata = textscan(fileID, '%s %s %s %s %s %s %s %s');


Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by