Azzera filtri
Azzera filtri

Using strrep on cell array with some non-chars

13 visualizzazioni (ultimi 30 giorni)
Mads
Mads il 30 Set 2011
Commentato: Alexei il 16 Ott 2014
Hi all.
I have this set of data structured as an array of cells which contain chars in almost all cells. However, a few cells contain NaN as double.
Now, I want to use the function 'strrep' on this array of cells as I need to exchange ',' and '.'.
Does anyone have an efficient solution to this?
Thanks a lot

Risposta accettata

Jan
Jan il 30 Set 2011
C = {'1,2', NaN, '3,14'};
isString = cellfun('isclass', C, 'char');
C(isString) = strrep(C(isString), ',', '.');
  2 Commenti
Mads
Mads il 3 Ott 2011
Perfect, thank you.
Alexei
Alexei il 16 Ott 2014
Guys,
What in the world is " isclass "?? There is NO Mathworks page for it. Typing in doc isclass brings up nothing. However, following the example given by Jan Simon, it still works. What is going on?? Is this a former function that Mathworks wants to retire? If so, then what is the appropriate substitute to use? I tried using cellfun('class',C,'char') instead, but that gave me an "Unknown option" error.
Thanks!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by