MATLAB: How to convert every floating value in cell to integer

cellcell arraysconvertdata type conversionMATLAB

I have a cell with matrices of different sizes in it .I want to convert every floating value in cell to integer. I tried int16 function but apparently it can only be used for arrays..is there any function for cells?

Best Answer

Not with a standard function. However, it is possible with a small script
>> cellfun( @(num) int16(num), {[1,2,3],[4,5]; [6], [7,8] }, 'uni', false )
ans =
[1x3 int16] [1x2 int16]
[ 6] [1x2 int16]