Convert a string of numbers to a number.

3 ビュー (過去 30 日間)
Poras K
Poras K 2016 年 10 月 5 日
回答済み: Jos (10584) 2016 年 10 月 5 日
Convert a string of numbers to a number without using str2num.
  1 件のコメント
KSSV
KSSV 2016 年 10 月 5 日
Why not str2num?

サインインしてコメントする。

採用された回答

Abhishek Jain
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.

その他の回答 (1 件)

Jos (10584)
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 = ...

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by