show_precision.m

来自「实现地震勘探中」· M 代码 · 共 54 行

M
54
字号
function show_precision(ds)% Function checks numeric fields of specific structures (seismic, well log, % table, pseudo-wells) to see if they have all the same precision.%% Written by: E. R.: December 31, 2006% Last updated: January 7, 2007: Generalize for dataset vectors% %      ds=show_precision(ds)% INPUT% ds   dataset of type "seismic', "well_log", "table",' or "pseudo-well"%% EXAMPLE%    show_precision(s_data)if nargin ~= 1   error(' One input argument is required.')endif strcmp(ds(1).type,'seismic')	 ||  strcmp(ds(1).type,'well_log') ...                                 ||  strcmp(ds(1).type,'table') ...                                 ||  strcmp(ds(1).type,'pseudo-wells')    lds=length(ds);   for jj=1:lds      fnames=fieldnames(ds(jj));      lfnames=length(fnames);      bool1=false(lfnames,1);      bool2=false(lfnames,1);      for ii=1:lfnames         if isa(ds(jj).(fnames{ii}),'double')            bool2(ii)=true;         elseif isa(ds(jj).(fnames{ii}),'single')            bool1(ii)=true;         end      end      if lds > 1         disp([' Dataset # ',num2str(jj),':'])      end      if any(bool1)         if any(bool2)   % Mixed precision            disp(' Single precision:')       	    disp(['   ',cell2str(fnames(bool1),', ')])            disp(' Double precision:')	    disp(['   ',cell2str(fnames(bool2),', ')])         else            disp(' Single precision')         end      else         disp(' Double precision')      end   end else   error('Function "same_precision" is not defined for this input argument.')end

⌨️ 快捷键说明

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