フィルターのクリア

invalid file identifier. use fopen to generate a valid file identifier

46 ビュー (過去 30 日間)
Guillermo Arias
Guillermo Arias 2021 年 8 月 13 日
回答済み: Muhammed Yaseen 2021 年 8 月 17 日
Hi, I have a problem with extracting data from my main code. I generated a .exe archive and I want to extract some data to a .txt archive. When I run the code in Maltab it works perfectly but in the .exe I got the error message: invalid file identifier. use fopen to generate a valid file identifier.
How can I fix it?. Thank you very much.
  2 件のコメント
dpb
dpb 2021 年 8 月 13 日
More than likely you're not using a fully-qualified file name and the installed location of the .exe isn't in the same place as the MATLAB function/script.

サインインしてコメントする。

回答 (1 件)

Muhammed Yaseen
Muhammed Yaseen 2021 年 8 月 17 日
This is due to the fact that all deployed applications look for a file relative to the "ctfroot", unless the file has been packaged along with the application while compiling it.
As a workaround, use the entire path of the file as the argument to the "fopen" command as shown below:
>> [FileName,PathName] = uigetfile('*.csv')
>> fullpath = [PathName FileName];
>> fid = fopen(fullpath);
The file identifier would now be valid.
For more details on "ctfroot", you can refer this link.

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by