- Extract the string from the cell.
- Replace the comma with a period.
- Convert the string to a double.
How to convert cell aray which contains numeric to double
조회 수: 1 (최근 30일)
이전 댓글 표시
채택된 답변
Vaibhav
2024년 2월 9일
Hi Arif
I understand that you would like to convert cell aray which contains numeric to double. You can consider following the below steps:
Here's an example code:
% Cell array with a string containing a comma as decimal separator
cellArray = {'0,037796'}
% Extract the string from the cell
stringValue = cellArray{1};
% Replace the comma with a period
stringValue = strrep(stringValue, ',', '.');
% Convert the string to a double
doubleValue = str2double(stringValue)
% If you want to convert to a number without decimals (as your example suggests)
% you would remove the decimal point before converting
stringValueNoDecimal = strrep(stringValue, '.', '')
% Now convert the modified string to a double
doubleValueNoDecimal = str2double(stringValueNoDecimal)
% Display the result
disp(doubleValue);
Hope this helps!
추가 답변 (0개)
참고 항목
카테고리
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!