📄 rdhead.m
字号:
function [nb, nt, off] = rdhead(fid, verbose);
% rdhead.m reads the header data from an RDI ADCP binary file
%
%function [nb, nt, off] = rdhead(fid, verbose);
%
% fid = file handle returned by a previous fopen call
% nb = number of bytes in the ensemble
% nt = number of data types
% off = offset to the data for each type
% Set verbose = 1 for a text output.
% Written by Marinna Martini
% for the U.S. Geological Survey
% Atlantic Marine Geology, Woods Hole, MA
% 1/7/95
data = zeros(1,2);
fld=1;
if exist('verbose') ~= 1,
verbose = 0;
end
nb=[]; nt=[]; off=[];
% make sure we're looking at the beginning of
% the header record by testing for it's ID
junk=fread(fid,2,'uchar');
if((length(junk)~=2) | (ftell(fid)<0)),
disp('End of file found in rdhead.');
return;
end
if ((junk(1)~=127) | (junk(2)~=127)),
disp('Header ID not found');
return;
end
% get the number of bytes this ensemble
nb = fread(fid,1,'int16');
if verbose, disp(sprintf('Number of bytes per ensemble %d',nb)); end;
% get the number of data types
fseek(fid,1,'cof'); % skip spare byte position
nt=fread(fid,1,'uchar');
if verbose, disp(sprintf('Number of data types %d',nt)); end;
% get the type offset
off=zeros(nt,1);
for j=1:nt, off(j)=fread(fid,1,'int16'); end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -