フィルターのクリア

Using strrep on cell array with some non-chars

13 ビュー (過去 30 日間)
Mads
Mads 2011 年 9 月 30 日
コメント済み: Alexei 2014 年 10 月 16 日
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

採用された回答

Jan
Jan 2011 年 9 月 30 日
C = {'1,2', NaN, '3,14'};
isString = cellfun('isclass', C, 'char');
C(isString) = strrep(C(isString), ',', '.');
  2 件のコメント
Mads
Mads 2011 年 10 月 3 日
Perfect, thank you.
Alexei
Alexei 2014 年 10 月 16 日
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!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by