what is different between fget1 and fread ?

조회 수: 3 (최근 30일)
yanjie qi
yanjie qi 2016년 3월 2일
편집: Walter Roberson 2016년 3월 6일
path='F:\多光谱材料\2\2.hdr';
>> fnm='2.hdr';
>> I=enviread(path,fnm);
??? Error using ==> fgetl at 44
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in ==> enviread>read_envihdr at 190
line = fgetl(fid);
Error in ==> enviread at 16
info=read_envihdr(hdrfile);

채택된 답변

Mohammad Abouali
Mohammad Abouali 2016년 3월 2일
편집: Mohammad Abouali 2016년 3월 2일
I don't think enviread is a function provided by mathworks. It appears it is something that users have provided.
Try multibandread() function of matlab to read ENVI files. I use this function when I am reading ENVI files and it works very well. If you want some instruction on how to use it to read ENVI files, the following is a good resource.
  댓글 수: 3
yanjie qi
yanjie qi 2016년 3월 5일
편집: Walter Roberson 2016년 3월 6일
SIR,
I want to convert the data(2-array ) into an image? but the elements are too many, can you give me some suggestions, appreciate on it
Mohammad Abouali
Mohammad Abouali 2016년 3월 6일
I am not sure if I understand thequestion

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

추가 답변 (1개)

Jan
Jan 2016년 3월 2일
Do not overwrite the important Matlab function path with a variable. Although this will not be the reason of the error, it is a bad idea and might cause severe problems during debugging.
The error means, that the file could not be opened. Most likely the file or folder name is not correct.
I do not see a relation between the error message and the title "difference between fget1 and fread". As the docs explain, fgetl reads a complete line from a text file, while fread reads a specified number of elements from a text or binary file in a specified format.
  댓글 수: 2
yanjie qi
yanjie qi 2016년 3월 3일
thank you, sir
I know that path is a matlab variable, this is not the main error.I tried to put .hdr .raw and M file togeter,and ran it. This time it with such error, I will show you :
??? Undefined function or method 'fget1' for input arguments of type 'double'.
Error in ==> enviread>read_envihdr at 190 line = fget1(fid);
Error in ==> enviread at 16 info=read_envihdr(hdrfile);
also I load the original file.
Jan
Jan 2016년 3월 3일
편집: Jan 2016년 3월 3일
Do you see, that your command is called "fetg1" with a trailing "one" not an lower-case "L"? The attached code uses "fgetl" with an L. So you error message does not match the code - please do not confuse the readers with such jokes.
The code is instable. The comparison " if varargin{2}=='date' " will fail with an error, if the 2nd input does not have 4 characters. Use this instead:
if strcmp(varargin{2}, 'date')
The eval s are such ugly!
eval(['info.',param,' = ''',value,''';'])
What about:
info.(param) = value;

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

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by