Input file error in Matlab.

조회 수: 3 (최근 30일)
Brian
Brian 2012년 10월 31일
I've been trying to run a program in Matlab for awhile now, but it requires an input file to run properly. Attempting to enter the name of the input file I want to use keeps returning this error message:
Error using fgets
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in truss2n>InputData (line 53)
DUMMY = fgets(LINP);
Error in truss2n (line 13)
InputData;
Does anyone know what I'm doing wrong? What Matlab window does my input file need to be displayed in, and what extension does it need to have? How do I make sure that the program can recognize the input file?

채택된 답변

Jan
Jan 2012년 10월 31일
The problem is caused at the command fopen. There is no file with the provided file name. Thius exception should be checked:
LINP = fopen(FileName);
if LINP == -1
error('Cannot open file for reading');
end
...
I do not assume, that this has anything to do with Matlab windows, the files need not be displayed for opening and the extension does not matter also. I'm convinced, that you simply use a wrong file name or path.
  댓글 수: 1
Brian
Brian 2012년 11월 3일
Got the input file working, thanks for the help.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by