MATLAB: Removing NaN from matrix with strings and numbers

matrix nan cell string number

I'm having trouble removing NaN from this matrix
cabos=
[1x26 char] 'InĂ­cio' 'Fim' [1x20 char] 'N. volt. level [KV]'
[2.0088e+03] 'SE S M Portuzelo' 'PTD 0526' [ 18.6057] [ 15]
[ 169.0442] 'PTC 5452' 'PTD 0450' [ 18.6057] [ 15]
[ 446.3509] 'PTD 0039' 'PTC 2850' [ 18.6057] [ 15]
[ 635.2552] 'PTD 0450' 'PTD 0039' [ 18.6057] [ 15]
[ 255.5464] 'PTD 0450' 'PTD 0090' [ 18.6057] [ 15]
[4.2281e+03] 'PTD 0526' 'PTC 5452' [ 18.6057] [ 15]
[ NaN] [ NaN] [ NaN] [ NaN] [ NaN]
[ NaN] [ NaN] [ NaN] [ NaN] [ NaN]
[ NaN] [ NaN] [ NaN] [ NaN] [ NaN]
I tried this code and it removes de NaN values, but it completely rearanges the matrix and i can't solve this
cabos(cellfun(@(cabos) any(isnan(cabos)),cabos)) = []

Best Answer

Possibly, this is what you want. But see comments to your question.
cabos(cellfun(@(c) isscalar(c) && isnan(c), cabos)) = {[]}
This will replace NaNs with empty matrices. The benefit of which is not obvious to me.