Error using fclose in MATLAB on Mac: "Invalid file identifier. Use fopen to generate a valid file identifier.

조회 수: 2 (최근 30일)
Hi everyone,
I'm encountering an issue with MATLAB that's been perplexing me since I switched from using a Windows system to a Mac. Whenever I run my script, I'm faced with the error message: "Error using fclose - Invalid file identifier. Use fopen to generate a valid file identifier."
Oddly enough, this script worked flawlessly on my old computer running MATLAB 2023a (on Windows), but the problem surfaced after I upgraded to MATLAB 2023b on my new Mac system.
I've checked and rechecked my code, and everything seems to be in order. So, I'm reaching out to see if anyone else has encountered a similar issue or has any insights into what might be causing this discrepancy between systems.
Any help or suggestions would be greatly appreciated. Thank you in advance!
Best regards,
Chen

답변 (1개)

Steven Lord
Steven Lord 2024년 4월 15일
When you call fopen you should call it with two output arguments and check if the first is -1. If it is, that means MATLAB and/or your OS was not able to open your file. In that case, the second output argument will include additional information about why the file couldn't be opened.
My guess is you didn't have permission to open the file in that location.
  댓글 수: 2
HSIN-Yi CHEN
HSIN-Yi CHEN 2024년 4월 15일
Hi Steven,
I've tried to used the fopen commend and the output of the fileID is 3 rather than -1. Do you have any idea for what might be the issue?
Thanks
Steven Lord
Steven Lord 2024년 4월 15일
Can you show us a small segment of code (no more than a dozen lines) that demonstrate the problem?

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

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by