Conversion of cell element to double
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello.
I want to convert a cell element to double array element. I know the command to do this is str2double but the problem is that the cell element has a number along with a letter that I want to omit. I will try to explain it through the following example.
Cell element: '123456789 a'
Double element (by using str2double): NaN
I want to retain just the numeric part of the cell element. So I would want 123456789 as the double element in the above example. Can anyone please help as to how to go about this?
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2015년 12월 28일
a={'123456789 a' '455'}
b=regexp(a,'\d+','match')
c=cellfun(@(x) str2double(x{1}),b)
댓글 수: 3
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!