MATLAB: How do replace NaN values and delete full zero’s columns from matlab table

MATLABtableuitable

Dear experiences …
i have a data stored in excel file which contain some empty cells (no values)..
  • when i read this data by use read table.. i need to replace first NaN table cells by 0.
  • then .. eliminate columns that fully contain 0's values along with header names ..
thanks

Best Answer

k = rand(10) ; % some random data
% put some Nan's
k(randsample(1:numel(k),10)) = NaN ;
% make a column zero
k(:,7) = 0 ;
% replace Nan's with zeros
k(isnan(k)) = 0 ;
k=k(:,any(k)) ; % remove columns with zeros