Home > database > ensemble_remove_empty_vars.m

ensemble_remove_empty_vars

PURPOSE ^

Removes variables from an Ensemble datastruct whose values are all empty

SYNOPSIS ^

function data_st = ensemble_remove_empty_vars(data_st)

DESCRIPTION ^

 Removes variables from an Ensemble datastruct whose values are all empty

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function data_st = ensemble_remove_empty_vars(data_st)
0002 % Removes variables from an Ensemble datastruct whose values are all empty
0003 %
0004 
0005 % 21Jun2013 Petr Janata
0006 
0007 nvars = length(data_st.vars);
0008 rmvars = [];
0009 for ivar = 1:nvars
0010   if iscell(data_st.data{ivar})
0011     if all(cellfun('isempty',data_st.data{ivar}))
0012       rmvars(end+1) = ivar;
0013     end
0014   else
0015     if all(isnan(data_st.data{ivar}))
0016       rmvars(end+1) = ivar;
0017     end
0018   end
0019 end
0020 
0021 fprintf('Removing %d empty variables from data struct\n', length(rmvars));
0022 data_st.vars(rmvars) = [];
0023 data_st.data(rmvars) = [];
0024 
0025 end
0026

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003