필터 지우기
필터 지우기

how can i resolve this issue of fread command

조회 수: 6 (최근 30일)
tauqeer
tauqeer 2013년 5월 9일
plz help me out i m recieving this error, dont know what it means and how to resolve it, have tried different versions of matlab and recieved same error this code executed successfully just once now this error is visible
"name=uigetfile('*.*');
file_open=fopen(name,'r');
file_read=fread(file_open,'uint8');
fclose(file_open);
a=file_read;"
*_Error using fread Invalid file identifier. Use fopen to generate a valid file identifier.
Error in bwtenc (line 4) file_read=fread(file_open,'uint8');_*

답변 (2개)

michael scheinfeild
michael scheinfeild 2013년 5월 9일
편집: Walter Roberson 2013년 5월 9일
openonly one file at time , see if the file name is correct
fid = fopen("fname.txt","rt")
data=fread(fid,inf);% of data= fscanf
fclose(fid)
if it is binary open by fid=fopen("fname.bin","rb")
  댓글 수: 2
tauqeer
tauqeer 2013년 5월 9일
brother i m opening only one file + file name is also correct have executed this code it had just worked once now i m recieving error.
Walter Roberson
Walter Roberson 2013년 5월 9일
MATLAB opens in binary unless you use the 't' flag. This is opposite of C's convention.

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


Walter Roberson
Walter Roberson 2013년 5월 9일
[filename, filepath] = uigetfile('*.*');
name = fullfile(filepath, filename);
file_open = fopen(name, 'r');
file_read = fread(file_open,'uint8');
fclose(file_open);
a = file_read;
My guess is that one of the times you were already in the correct directory and the other times you were in a different directory than where your files were located.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by