% % ----------------- % Copyright © 2019 ACK Cyfronet AGH, Poland. % % This work was partially funded by EPOS Project funded in frame of PL-POIR4.2 % -------------- % function varargout = eliminateEmptyValues(varargin) % ELIMINATEEMPTYVALUES Removes empty values from input columns % % [out1, out2, ...] = ELIMINATEEMPTYVALUES(in1, in2, ...) removes empty % or NaN values from the input columns. The function takes a variable % number of input arguments and returns the corresponding output columns % without empty or NaN values. The inputs can be numeric arrays or cell % arrays, and the function will remove entries that are empty in any of % the input columns. % % This function is designed to work with catalog objects. For more % information about the catalog format, refer to the documentation: % https://docs.cyfronet.pl/display/ISDOC/Catalog+-+description % % Example: % [a, b] = eliminateEmptyValues([1, NaN, 3], {'A', '', 'C'}); % % Result: a = [1, 3], b = {'A', 'C'} % if isempty(varargin) return; end indexes = 1:length(varargin{1}); for i = 1:length(varargin) column = varargin{i}; if isnumeric(column) indexes = intersect(indexes, find(~isnan(column))); elseif iscell(column) indexes = intersect(indexes, find(~cellfun(@isempty, column))); end end for i = 1:length(varargin) varargout{i} = varargin{i}(indexes); end end