Filter löschen
Filter löschen

Combining vectors [1 2 3 4 5] and [2 3 4 1 5] to [12 23 34 41 55]

1 Ansicht (letzte 30 Tage)
Redstein
Redstein am 19 Mär. 2019
Bearbeitet: Andrei Bobrov am 19 Mär. 2019
Hi everybody,
I want to combine two vectors to one, but am not able to find an equivalent example.
I have two vectors that I want to combine as following:
[1 2 3 4 5] and [2 3 4 1 5] to [12 23 34 41 55]
Is there an elegant way to code this?
Thanks a lot!

Akzeptierte Antwort

Torsten
Torsten am 19 Mär. 2019
Bearbeitet: Torsten am 19 Mär. 2019
v = 10*v1 + v2

Weitere Antworten (1)

Andrei Bobrov
Andrei Bobrov am 19 Mär. 2019
Bearbeitet: Andrei Bobrov am 19 Mär. 2019
A = [1 200 3 4 5];
B = [23 3 445 10 54];
out = str2double(string(A)+B);
or
out = A.*10.^(floor(log10(B))+1) + B;

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by