-1
Chan 1:
 -7.33475E-0001  1.03285E+0000  1.67651E+0000  5.98755E-0002 -8.23288E-0001  4.93973E-0001  1.36217E+0000  1.34720E-0001 -8.08319E-0001  4.64035E-0001
  1.70645E+0000  5.98755E-0001 -8.53226E-0001  1.49689E-0002  1.60167E+0000  1.09273E+0000 -2.54471E-0001  4.19128E-0001  2.12558E+0000  1.73639E+0000
 -4.49066E-0002 -1.04782E-0001  1.45198E+0000  1.49689E+0000 -1.64658E-0001 -4.19128E-0001  1.16757E+0000  1.51186E+0000 -1.19751E-0001 -7.78381E-0001
  7.33475E-0001  1.69148E+0000  3.44284E-0001 -7.33475E-0001  4.93973E-0001  1.57173E+0000  3.44284E-0001 -1.04782E+0000 -7.48444E-0002  1.51186E+0000
  9.28070E-0001 -5.08942E-0001  4.49066E-0002  1.49689E+0000  1.03285E+0000 -5.38879E-0001 -2.09564E-0001  1.60167E+0000  1.63161E+0000 -1.64658E-0001\n
Chan 2:
 -5.53848E-0001  1.00291E+0000  1.37714E+0000 -2.69440E-0001 -8.38257E-0001  8.83163E-0001  1.85614E+0000  4.49066E-0001 -6.28693E-0001  6.43661E-0001
  1.94595E+0000  8.83163E-0001 -4.64035E-0001  4.93973E-0001  1.90105E+0000  1.13763E+0000 -4.19128E-0001  7.48444E-0002  1.69148E+0000  1.30229E+0000
 -3.74222E-0001 -3.44284E-0001  1.22745E+0000  1.30229E+0000 -3.89191E-0001 -6.88568E-0001  1.07776E+0000  1.66154E+0000  1.34720E-0001 -6.28693E-0001
  6.13724E-0001  1.25739E+0000 -4.49066E-0002 -8.08319E-0001  6.88568E-0001  1.93098E+0000  7.33475E-0001 -7.48444E-0001  8.98132E-0002  1.55676E+0000
  8.38257E-0001 -6.73599E-0001  1.49689E-0001  1.90105E+0000  1.46695E+0000 -3.44284E-0001 -2.39502E-0001  1.34720E+0000  1.28732E+0000 -2.84409E-0001
 -4.04160E-0001  1.15260E+0000  1.42204E+0000 -2.39502E-0001 -8.38257E-0001  7.48444E-0001  1.69148E+0000  3.14346E-0001 -6.58630E-0001  6.13724E-0001
  1.70645E+0000  5.23911E-0001 -7.18506E-0001  4.49066E-0001  1.97589E+0000  
1.13763E+0000 -3.14346E-0001  3.44284E-0001  1.85614E+0000  1.21248E+0000\n
Chan 3:
 -6.28693E-0001 -4.34097E-0001  1.25739E+0000  1.25739E+0000 -4.19128E-0001 -6.88568E-0001  8.38257E-0001  1.15260E+0000 -4.19128E-0001 -9.58008E-0001
  6.28693E-0001  1.55676E+0000  2.84409E-0001 -5.83786E-0001  7.48444E-0001  1.82620E+0000  6.28693E-0001 -5.53848E-0001  5.38879E-0001  1.91602E+0000
  1.00291E+0000 -5.38879E-0001  0.00000E+0000  1.45198E+0000  8.23288E-0001 -8.53226E-0001 -5.98755E-0001  1.06279E+0000  1.06279E+0000 -4.79004E-0001\n

这些是 sismic 数据,我想读取这些数据并保存在不同的变量 X、Y、Z 中。Chanel 1=x Chanel 2=y Chanel 3=z 然后我想绘制它。

4

1 回答 1

0

我会通过一次读取一行文件来执行此操作,检查该行是否是块标记,如果不使用 textscan 来解析该行中的双精度数。

fid = fopen('c:\temp\temp.txt');
vars = {'X','Y','Z'};
varIndex = 0;
current = [];
while 1
    tline = fgetl(fid);
    if ~ischar(tline), break, end

    newVar = ~isempty(strfind(tline,'Chan'));

    if newVar
        if varIndex > 0
            eval([ vars{varIndex} '=current;']);
            current = [];
        end
        varIndex = varIndex + 1;
    else
        newData = textscan(tline,'%f');
        current = [current newData{:}'];
    end    
    disp(tline)
end

eval([ vars{varIndex} '=current;']);
current = [];

fclose(fid)
于 2012-10-03T09:09:28.670 回答