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

1 次查看(过去 30 天)
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!

采纳的回答

Torsten
Torsten 2019-3-19
编辑:Torsten 2019-3-19
v = 10*v1 + v2

更多回答(1 个)

Andrei Bobrov
Andrei Bobrov 2019-3-19
编辑:Andrei Bobrov 2019-3-19
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;

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by