convert cell array into double and remove dollar symbol

조회 수: 5 (최근 30일)
Salvatore Lacava
Salvatore Lacava 2017년 7월 8일
답변: Jan 2017년 7월 8일
Hi everyone, I was working on an assignment and I got stuck into converting a cell array of the type: a = {'$12,001.87','$0.04','$12,003,887.55','$0.32'}; into numeric values that I can finally sum up. I tried str2double but I have got NaNs probably because of the dollar symbol that I should remove (not sure though). Can someone please help me with this?

채택된 답변

Jan
Jan 2017년 7월 8일
C = {'$12,001.87','$0.04','$12,003,887.55','$0.32'};
C = strrep(C, '$', '');
C = strrep(C, ',', '');
N = str2double(C)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by