How to combine two arrays

4 views (last 30 days)
MIch
MIch on 30 Sep 2022
Commented: MIch on 30 Sep 2022
Hello,
for example there are a= [3 5 1] and b = [4 6 7]
How can I combine a and b to get c= [3 4 5 6 1 7]?

Accepted Answer

Robert U
Robert U on 30 Sep 2022
Hi MIch,
have a look in the documentation under language fundamentals --> reshape()
a = [3 5 1];
b = [4 6 7];
c= reshape([a' b']',1,[])
c = 1×6
3 4 5 6 1 7
Kind regars,
Robert
  1 Comment
MIch
MIch on 30 Sep 2022
Thank you very much

Sign in to comment.

More Answers (1)

zhehao.nkd
zhehao.nkd on 30 Sep 2022
Try reshape([a;b],1,[])
  1 Comment
MIch
MIch on 30 Sep 2022
Thank you very much

Sign in to comment.

Categories

Find more on Data Types in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by