# How to convert a 1D vector in number?

11 visualizzazioni (ultimi 30 giorni)
ankita il 13 Ago 2013
e.g barcode=[8 9 0 2 0 8 0 0 1 1 4 4 5] How i get A=8902080011445 ??
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Evan il 13 Ago 2013
Modificato: Evan il 13 Ago 2013
>> barcode = [8 9 0 2 0 8 0 0 1 1 4 4 5];
>> n = polyval(barcode,10)
n =
8902080011445
Or, without polyval:
>> n = sum(barcode .* 10.^[(numel(barcode)-1):-1:0])
n =
8902080011445
Note that this assumes all elements of barcode are single-digit. If this is not the case, but you want something similar, this would work:
>> barcode = [8 9 0 2 0 8 0 0 1 1 4 86 5];
>> n = str2num(regexprep(num2str(barcode),' ',''))
n =
89020800114865
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
ankita il 13 Ago 2013
thanx we have just tried it out..

Accedi per commentare.

### Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by