Detecting and eliminating numbers from a cell matrix that contains NaNs and string characters
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dear all, I have a cell matrix An example is the following
total(1:20,1:2)
ans =
[ NaN] [ NaN]
[ NaN] [ NaN]
[ NaN] [ NaN]
'England' [ NaN]
[ NaN] [ NaN]
[ NaN] [ NaN]
' AUSTRIA' ' SMOKES'
[1x20 char] 'NIKE'
[1x26 char] [1x46 char]
[1x26 char] [1x41 char]
[1x26 char] [1x38 char]
[1x20 char] 'GOODYS'
[1x26 char] [1x56 char]
[1x26 char] [1x48 char]
[1x26 char] [1x47 char]
' BAND 1' 'HIT'
' BAND 2 KA 1' [1x39 char]
' BAND 2 KA 2' [1x42 char]
' BAND 2 KA 3' [1x47 char]
' BAND 2 KA 4' 'YES'
The problem is that sometimes these 2 columns contain numbers in some cells, like zero, and this distorts the analysis. Is it possible to detect such numbers and if exist eliminate then from the corresponding cells?
thanks
0 Commenti
Risposta accettata
Andrei Bobrov
il 2 Lug 2012
Modificato: Andrei Bobrov
il 2 Lug 2012
A = {[ NaN] [ NaN]
[ NaN] [ NaN]
[ NaN] [ NaN]
'England' [ NaN]
[ NaN] [ NaN]
[ NaN] [ NaN]
' AUSTRIA' ' SMOKES'
'tetete' 'NIKE'
'jhjh khkhkh' 'GOODYS'
' BAND 1' 'HIT'
' BAND 2 KA 1' 'eerrrr'
' BAND 2 KA 2' 'dddddd'
' BAND 2 KA 3' [ NaN]
' BAND 2 KA 4' 'YES' };
eg
A(cellfun(@(x)isnumeric(x)&~all(isnan(x)),A)) = {NaN};
OR just
A(cellfun(@(x)isnumeric(x),A)) = {NaN};
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Operators and Elementary Operations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!