Error using textscan Invalid file identifier. Use fopen to generate a valid file identifier.

5 views (last 30 days)
I'm doing a simulation using MATLAB. There is a python code that reads the plain-text files for model setup and generates text files easy to import by Matlab. The program makes plain-text files containing number of values and a column of values. However, when I run the program in MATLAB the following error occurs:
Error using textscan
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in load_setup>load_word (line 247)
temp=textscan(fid,'%d'); % eat up default '1'
Error in load_setup (line 59)
Model.code=load_word(standard_folder_name,'Model_code');
Error in Simulate (line 57)
[conditions, modes, Model]=load_setup(setup_name, model_name);
I don't know exactly what to do.
  3 Comments
Ashkan Shahsavan
Ashkan Shahsavan on 16 Jul 2020
I'm sure about the presence of the file in the working directory since when I change the working directory, the error is changed to file not found. And what do you mean by fully-qualified filename? Thanks for your answer.
dpb
dpb on 16 Jul 2020
"what do you mean by fully-qualified filename?"
One that includes the path, not just the file name.
Well, we can't tell from here what the script is doing -- since it didn't test for valid fid on fopen but just let the system error message report, you don't know anything else, specifically.
Set a breakpoint in the script/function and see what gives -- you can add the optional error message return to fhe fopen call and see what the actual error returned was...
Or, if it's a script, maybe they presumed you had already opened the file yourself first??? We simply can't tell.
Also, of course, make sure you're actually running the script (or the script/function itself is running in the location you think--maybe it tries to be clever and does a cd inside to where it thinks the input files should be...

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!