是什么导致MATLAB中的文件标识符无效? [英] What causes an invalid file identifier in MATLAB?

查看:3824
本文介绍了是什么导致MATLAB中的文件标识符无效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MATLAB脚本,我上一次使用它(一年前)时就可以宣誓就可以了.现在,我收到此错误:

I have a MATLAB script that I could have sworn worked fine the last time I used it (a year ago). Now, I get this error:

Invalid file identifier.  Use fopen to generate a valid file identifier.

如果我理解正确,则无法找到或打开(?)脚本中其他位置指定的文件.这是正确的吗?如果是这样,可能是什么原因造成的?

If I understand correctly, it is failing to find or open(?) a file specified elsewhere in the script. Is this right? If so, what could cause it?

推荐答案

fid(文件标识符)是fopen的输出.这是一个整数,但与文件永久无关.您需要使用fopen来获取fid.在我看来,您在某些与文件相关的I/O命令(例如freadfscanffclose)中使用了错误的fid(文件标识符).不成功的fopen给出-1fid.对于任何有效的普通文件,成功的fopen都将给出fid3或更大的整数.

fid (file identifier) is the output of fopen. It's an integer, but not related to the file permanently. You need to use fopen to get the fid. It seems to me that you are using incorrect fid (file identifier) in some file-related I/O command, such as fread, fscanf or fclose. Unsuccessful fopen gives fid of -1. For any valid normal file successful fopen will give fid that is 3 or greater integer.

但是,没有任何代码,就不可能说出错误或错误在哪里或什么地方.您可以使用MATLAB调试器从相关的fopen中单步执行代码(在此处设置断点并运行程序),直到相关的fclose并查看fid(或用于文件标识符的任何变量名称)或其他文件标识符的数据结构(如果您的代码中有多个文件标识符)在相关的fopenfclose之间的任何一点上都会发生变化.

However, without any code it's impossible to say where or what the bug or error is. You could use MATLAB debugger to single-step the code from relevant fopen (set breakpoint there and run your program) until the relevant fclose and see if fid (or whatever variable name you use for file identifier) or any data structure for your file identifiers (if have more than one file identifier in your code) changes in any point between relevant fopen and fclose.

这篇关于是什么导致MATLAB中的文件标识符无效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆