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

조회 수: 2 (최근 30일)
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
Ashkan Shahsavan
Ashkan Shahsavan 2020년 7월 16일
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 2020년 7월 16일
"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...

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Standard File Formats에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by