readmala.m

来自「于探地雷达的matlab正演程序」· M 代码 · 共 46 行

M
46
字号
function [Header,Data]=readmala(file)
% READMALA is a function that imports GPR data collected with a MALA GPR 
% Header is a structure with fields the definition of the mala *.rad file
% Data is a matrix of [samples,traces] size which is read from the *.rd3 file
% file is a string containing the name of the scan without the extension!
% A. Giannopoulos, 2003

HeaderFile=[file '.rad'];
DataFile=[file '.rd3'];

fid=fopen(HeaderFile);
if fid == -1
    error('Can not open file');
end

count=0;
while 1
    linein=fgetl(fid);
    if linein==-1
        break
    else
        count=count+1;
        Head{count}=linein;
    end
end
Header=0;
for k=1:count
    SeparatorLocation=findstr(Head{k},':');
    tempfield=strrep(Head{k}(1:SeparatorLocation-1),' ','_');
    tempvalue=str2num(Head{k}(SeparatorLocation+1:end));
    Header=setfield(Header,tempfield,tempvalue);
end
fid2=fopen(DataFile);
if fid2 == -1
    error('Can not open file');
end

Data=fread(fid2,[Header.SAMPLES inf],'short');
   
fclose(fid);
fclose(fid2);  

      
        

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?