필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How can avoid following errors using MATLAB R2017a?

조회 수: 1 (최근 30일)
Freceena Francis
Freceena Francis 2018년 10월 4일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello, when l run a code I got this error in the function code given below. I don't know where this error is.
Error using fread
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in loadDepthMap>readHeader (line 57)
numFrames = typecast(uint8(fread(fid,4)), 'uint32');
Error in loadDepthMap (line 34)
[dims, numFrames] = readHeader(fid);
code:
function [depthMap] = loadDepthMap(path)
%%READING FROM FILE
fid = fopen(path); %Assign file reading object
[dims, numFrames] = readHeader(fid);
fileData = fread(fid, 'uint32');
fclose(fid); %close the stream
depth = double(fileData); %convert to double for imaging
depthCountPerMap = prod(dims);
depthMap = cell(1,numFrames);
for i=1 : numFrames
currentDepthData = depth(1:depthCountPerMap);
depth(1:depthCountPerMap) = [];
depthMap{i} = reshape(currentDepthData, dims(1), dims(2))'; %reshape depth into matrix
end
end
function [dims,numFrames] = readHeader(fid)
numFrames = typecast(uint8(fread(fid,4)), 'uint32');
dims(1) = typecast(uint8(fread(fid,4)), 'uint32');
dims(2) = typecast(uint8(fread(fid,4)), 'uint32');
end
  댓글 수: 2
KSSV
KSSV 2018년 10월 4일
The error says fread is unable to get the exact file or file location. Check to it that file is existing int he given path.
Freceena Francis
Freceena Francis 2018년 10월 5일
Thank You .. It really worked...

답변 (0개)

이 질문은 마감되었습니다.

태그

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by