Changeset 12303


Ignore:
Timestamp:
05/30/12 13:44:17 (13 years ago)
Author:
Mathieu Morlighem
Message:

Better input output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/utils/DataProcessing/gamv.m

    r12302 r12303  
    44%   Usage:
    55%      output = gamv(x,y,data,varargin)
     6
     7options=pairoptions(varargin{:});
     8
     9nlag = getfieldvalue(options,'nlag', 20);
     10dlag = getfieldvalue(options,'dlag', 1000);
    611
    712%Write data file
     
    2631fprintf(fid,'%-30s %s\n','-1.0e21 1.0e21'             ,'\trimming limits');
    2732fprintf(fid,'%-30s %s\n','gamv.out'                   ,'\file for variogram output');
    28 fprintf(fid,'%-30s %s\n','20'                         ,'\number of lags');
    29 fprintf(fid,'%-30s %s\n','5.0'                        ,'\lag separation distance');
    30 fprintf(fid,'%-30s %s\n','3.0'                        ,'\lag tolerance');
     33fprintf(fid,'%-30s %s\n',num2str(nlag,'%i')           ,'\number of lags');
     34fprintf(fid,'%-30s %s\n',num2str(dlag,'%g')           ,'\lag separation distance');
     35fprintf(fid,'%-30s %s\n',num2str(dlag/2,'%g')         ,'\lag tolerance');
    3136fprintf(fid,'%-30s %s\n','3'                          ,'\number of directions');
    3237fprintf(fid,'%-30s %s\n','0.0 90.0 50.0 0.0 90.0 50.0','\azm, atol, bandh, dip, dtol, bandv');
     
    4146%Call gamv
    4247system([issmdir() '/externalpackages/gslib/install/gamv gamv.par']);
     48delete('gamv.par');
     49
     50%Read output
     51output   = struct('Semivariogram',[],'Covariance',[]);
     52counter1 = 1;
     53counter2 = 1;
     54fid=fopen('gamv.out','r');
     55while (~feof(fid)),
     56        A=fscanf(fid,'%s',1);
     57        if strcmp(A,'Covariance');
     58                A=fscanf(fid,'%s',4); %Read tail:Data head:Data direction  2
     59                output(counter1).Covariance=fscanf(fid,'%i %g %g %i %g %g',[6 nlag+2])';
     60                counter1=counter1+1;
     61        elseif strcmp(A,'Semivariogram'),
     62                A=fscanf(fid,'%s',4); %Read tail:Data head:Data direction  2
     63                output(counter2).Semivariogram=fscanf(fid,'%i %g %g %i %g %g',[6 nlag+2])';
     64                counter2=counter2+1;
     65        else
     66                %do nothing
     67        end
     68end
     69fclose(fid);
     70delete('gamv.out')
Note: See TracChangeset for help on using the changeset viewer.