0001 function test = isnan_jd(var,svar,display_mode,ntab)
0002
0003 if nargin < 4,
0004 ntab = 0;
0005 end
0006
0007 if nargin < 3,
0008 display_mode = 0;
0009 end
0010
0011 if nargin < 2 || isempty(svar),
0012 svar = inputname(1);
0013 end
0014
0015 test = false;
0016
0017 if isnumeric(var),
0018
0019 nannum = sum(isnan(var(:)));
0020 if nannum > 0,
0021 disp_jd(display_mode,ntab + 2,['- Field ',svar,' : #NaN = ',num2str(nannum)]);
0022 test = true;
0023 end
0024
0025 elseif isstruct(var),
0026
0027 fnames = fieldnames(var);
0028
0029 for iarray = 1:length(var)
0030 disp_jd(display_mode,ntab,[' o recursively checking the structure ',svar,'(',num2str(iarray),') :'])
0031
0032 for ifield = 1:length(fnames),
0033
0034 fname = fnames{ifield};
0035 test = isnan_jd(var(iarray).(fname),fname,display_mode,ntab + 2) || test;
0036
0037 end
0038 end
0039
0040 elseif iscell(var),
0041
0042 disp_jd(display_mode,ntab,[' o checking the cell array ',svar,' as structure ',svar])
0043
0044 var = var(:);
0045 ncell = length(var);
0046 fnames = cell(ncell,1);
0047
0048 for icell = 1:ncell,
0049
0050 fnames{icell} = ['cell_',num2str(icell)];
0051
0052 end
0053
0054 var = cell2struct(var,fnames,1);
0055
0056 test = isnan_jd(var,svar,display_mode,ntab + 2);
0057
0058 elseif ~ischar(var),
0059
0060 disp_jd(display_mode,ntab,['Warning : variable ',inputname(1),' could not be tested : format not recognized']);
0061
0062 end
0063
0064 end
0065
0066 function disp_jd(display_mode,ntab,s)
0067
0068 if display_mode >= 1,
0069 disp([repmat(' ',[1,ntab]),s]);
0070 end
0071
0072 end