avatar
a question about Matlab fread# Computation - 科学计算
w*n
1
When I use fread , it always shows:
??? Error using ==> fread
Invalid file identifier -1.
I even tried some easy examples, the same warning came up.
What's wrong? Please help me:)
avatar
C*S
2
how you use this?
check help first!

【在 w*******n 的大作中提到】
: When I use fread , it always shows:
: ??? Error using ==> fread
: Invalid file identifier -1.
: I even tried some easy examples, the same warning came up.
: What's wrong? Please help me:)

avatar
r*y
3
This error message means that you did not open the file successfully at all.
Nothing to do with fread.
Moreover, c = fread(fid, 5) is wrong. You have to specify the data type, e.
g. fread(fid, 5, 'int'), to read 5 integers out.
I am not using matlab under windows. But I guess you can try to cd to that
directory first, then do fread.

【在 w*******n 的大作中提到】
: When I use fread , it always shows:
: ??? Error using ==> fread
: Invalid file identifier -1.
: I even tried some easy examples, the same warning came up.
: What's wrong? Please help me:)

avatar
w*n
4
I see. fid returns to -1 even I set that path.seems fopen can't open the file

all.
e.
that

【在 r****y 的大作中提到】
: This error message means that you did not open the file successfully at all.
: Nothing to do with fread.
: Moreover, c = fread(fid, 5) is wrong. You have to specify the data type, e.
: g. fread(fid, 5, 'int'), to read 5 integers out.
: I am not using matlab under windows. But I guess you can try to cd to that
: directory first, then do fread.

avatar
C*S
5
try fopen('filename.txt','rt')
and check help if you want to know why.

【在 w*******n 的大作中提到】
: I see. fid returns to -1 even I set that path.seems fopen can't open the file
:
: all.
: e.
: that

avatar
C*S
6
here is what I done, no problem on this.
EDU>> fid=fopen('single.txt','rt');
EDU>> s=fread(fid,5);
EDU>> sc=char(s)
sc =
a
b
c
d
e

occurred

【在 w*******n 的大作中提到】
: I see. fid returns to -1 even I set that path.seems fopen can't open the file
:
: all.
: e.
: that

avatar
w*n
7
Thanks. I got it:)

【在 C***S 的大作中提到】
: here is what I done, no problem on this.
: EDU>> fid=fopen('single.txt','rt');
: EDU>> s=fread(fid,5);
: EDU>> sc=char(s)
: sc =
: a
: b
: c
: d
: e

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。