MATLAB Answers

Redstein
0

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

Asked by Redstein
on 19 Mar 2019
Latest activity Edited by Andrei Bobrov
on 19 Mar 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!

  0 Comments

Sign in to comment.

Products


Release

R2018b

2 Answers

Answer by Torsten
on 19 Mar 2019
Edited by Torsten
on 19 Mar 2019
 Accepted Answer

v = 10*v1 + v2

  0 Comments

Sign in to comment.


Answer by Andrei Bobrov
on 19 Mar 2019
Edited by Andrei Bobrov
on 19 Mar 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;

  0 Comments

Sign in to comment.