Effacer les filtres
Effacer les filtres

Convert a string of numbers to a number.

4 vues (au cours des 30 derniers jours)
Poras K
Poras K le 5 Oct 2016
Convert a string of numbers to a number without using str2num.
  1 commentaire
KSSV
KSSV le 5 Oct 2016
Why not str2num?

Connectez-vous pour commenter.

Réponse acceptée

Abhishek Jain
Abhishek Jain le 5 Oct 2016
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.

Plus de réponses (1)

Jos (10584)
Jos (10584) le 5 Oct 2016
Look mammy, no hands!
S = '6387'
N1 = sscanf(S,'%d')
N2 = (S - '0') * (10.^(numel(S)-1:-1:0)).'
% N3 = ...

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by