Convert Cell array with numeric and non-numeric data into a numeric array.
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a cell array of data pulled from field measurements. This data should be numeric, but it sporadically has non numeric (e.g. "I/O Timeout") text strings in it. I'm loading this into MATLAB via xlsread. I'd like to convert this into a numeric array, and have all of the non-numeric values be converted to "NaN". It seems that this should be a pretty basic thing to do, but I have not found a way to do it yet. Cell2Mat wants every element to be of the same data type.
Thanks for any help.
-Mike A.
댓글 수: 0
채택된 답변
Fangjun Jiang
2011년 6월 17일
a={1,2,'timeout',3,4,'i/o'}
b=cellfun(@ischar,a)
a(b)={nan}
c=cell2mat(a)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!