%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% table = truncateValues(table,cols) table cell array or table where some columns have values that should be truncated cols index or indices of columns with values to be truncated Benjamin Sanchez Last edited: 2018-05-25 Eduard Kerkhoven Last edited: 2018-12-05 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0002 % table = truncateValues(table,cols) 0003 % table cell array or table where some columns have values that should 0004 % be truncated 0005 % cols index or indices of columns with values to be truncated 0006 % 0007 % Benjamin Sanchez Last edited: 2018-05-25 0008 % Eduard Kerkhoven Last edited: 2018-12-05 0009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0010 function table = truncateValues(table,cols) 0011 0012 [m,n] = size(table); 0013 for i = 1:m 0014 for j = cols 0015 orderMagn = max([ceil(log10(abs(table{i,j}))),0]); 0016 table{i,j} = round(table{i,j},6-orderMagn); 0017 end 0018 end 0019 end 0020 0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%