fgetl Error in Script

조회 수: 6 (최근 30일)
Richard Ward
Richard Ward 2018년 8월 1일
댓글: Walter Roberson 2025년 1월 6일
Hello,
I am encountering the following error:
"Error using fgetl (line 44)
Invalid file identifier. Use fopen to generate a valid file identifier."
I receive this error when running the following function:
[SL edited to remove the fgetl.m file shipped with MATLAB. Please don't post the code of MathWorks functions. If you want to refer to a function, it's probably sufficient to mention something like "the fgetl function in MATLAB" especially if you mention which release of MATLAB you're using.]
I'm still very novice at MATLAB programming, and am using this function in a larger script to process EEG data. For a full example of the script, please see: https://github.com/wp-erp/wp-erp/issues/692
Any assistance with this is greatly appreciated. Thanks!

답변 (1개)

Walter Roberson
Walter Roberson 2018년 8월 1일
You have to fopen() a file first. After you fopen() you should test if the value returned by fopen is negative: if it is then the fopen failed and you should advise the user and not continue. Then once you know the fopen worked, pass the value returned by fopen to fgetl.
  댓글 수: 3
野犬
野犬 2025년 1월 6일
hello,I meet same question,so what's wrong with my data?
Walter Roberson
Walter Roberson 2025년 1월 6일
[fid, msg] = fopen(FILENAME, 'r');
if fid < 0; error('failed to open file "%s" because "%s"', FILENAME, msg); end

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by