getcmp.m
来自「这是matlab在地球物理数据处理方面的源码」· M 代码 · 共 44 行
M
44 行
function [traces,offset]=GetCMP(str,CMPNumber)
%
% Function to get a set of traces and their offset from a
% file containing a set of CMP (or other) traces that you
% have previously saved using the function putcmp.m
% This would be used to save your cmp gathers if you desire so
% that you do not have to resort the data repeatedly.
% str=string of 7 character ????000
% examples nCMP000 (note the 000 will be converted to the appropriate CMPnumber
% you want to call the gather)
% CMPNumber: integer CMP number
% traces should contain a CMP gather
% offset should contain offsets of the CMP gather
% To run [traces,offset]=GetCMP('stuf000',29)gets a file with the name stuf029.dat
%
%
nt=1250;
filename=str;
filename(8:11)='.dat';
s=num2str(CMPNumber);
if(CMPNumber<10);
str(7:7)=s
elseif (CMPNumber<100);
str(6:7)=s
elseif(CMPNumber<999)
str(5:7)=s;
else
'error'
break
end
fid=fopen(filename,'r','l');
fseek(fid,0,'eof');
n=ftell(fid);
ntraces=n/4/(nt+1);
fseek(fid,0,'bof');
traces=zeros(nt,ntraces);
offset=zeros(1,ntraces);
for i=1:ntraces
offset(i)=fread(fid,1,'float');
traces(:,i)=fread(fid,nt,'float');
end
fclose(fid);
return
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?