필터 지우기
필터 지우기

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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by