i need to convert a string to a num without using the "str2num" function but in the final answer i have some undesired spaces. how can i remove them?
조회 수: 1 (최근 30일)
이전 댓글 표시
st = '23487';
x = double(st);
y = x-48;
y = 2 3 4 8 7
i want this in "normal" format of "23487"...
댓글 수: 2
Image Analyst
2012년 11월 24일
편집: Image Analyst
2012년 11월 24일
Is this a Homework question? If so, we'll give hints, but not the answer.
채택된 답변
Azzi Abdelmalek
2012년 11월 24일
편집: Azzi Abdelmalek
2012년 11월 24일
st = '14523'
x = double(st)
y = sum((x-48).*10.^(numel(st)-1:-1:0))
추가 답변 (1개)
Andrei Bobrov
2012년 11월 24일
편집: Andrei Bobrov
2012년 11월 26일
out = (st-'0')*10.^(numel(st)-1:-1:0)';
or from Cody
out = polyval(st-'0',10);
댓글 수: 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!