Hi,
I need to replace the NaNs in the columns a and b by empty cells. The code below works but it is pretty slow. Is there a faster way to do this ?
a = rand(1, 1000000)'; a(1:10000) = NaN;b = rand(1, 1000000)'; b(1:10000) = NaN;c = repelem({'A101'}, 1000000)';t = table(a, b, c);var_names = t.Properties.VariableNames;for ii = 1:length(var_names) if ~iscell(t.(var_names{ii})) t.(var_names{ii}) = cellstr(num2str(t.(var_names{ii}))); idx = contains(t.(var_names{ii}), 'NaN'); t.(var_names{ii})(idx) = {''}; endend
Thank you,
Best Answer