Convert a string of numbers to a number.
조회 수: 4 (최근 30일)
이전 댓글 표시
Convert a string of numbers to a number without using str2num.
채택된 답변
Abhishek Jain
2016년 10월 5일
You can use the following code.
a=[1 2 3];
b=length(a);
c=(b-1):-1:0
d=10.^c;
y=a.*d;
It converts an array containing digits to a number.
Hope that helps.
댓글 수: 0
추가 답변 (1개)
Jos (10584)
2016년 10월 5일
Look mammy, no hands!
S = '6387'
N1 = sscanf(S,'%d')
N2 = (S - '0') * (10.^(numel(S)-1:-1:0)).'
% N3 = ...
댓글 수: 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!