MATLAB Answers

convert cell array into double and remove dollar symbol

Salvatore Lacava 님이 질문을 제출함. 8 Jul 2017
최근 활동 Jan 님이 답변함. 8 Jul 2017
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?

  댓글 수: 0

로그인 to comment.

답변 수: 1

Jan 님의 답변 8 Jul 2017
 채택된 답변

C = {'$12,001.87','$0.04','$12,003,887.55','$0.32'};
C = strrep(C, '$', '');
C = strrep(C, ',', '');
N = str2double(C)

  댓글 수: 0

로그인 to comment.



Translated by