Convert a string of numbers to a number.
3 次查看(过去 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!