How to add elements to the end of an array?

508 次查看（过去 30 天）
Angela Albrecht2016-10-27
I have two arrays:
alpha = [ 1 2 3 4 5]; beta = [ 6 7 8 9 10 11 12];
I'd like to add beta to the end of alpha so they form gamma
gamma = [1 2 3 4 5 6 7 8 9 10 11 12];
How would I go about doing this?
3 个评论显示 2更早的评论隐藏 2更早的评论
Thanks for this info.

采纳的回答

John Wirzburger 2016-10-27
gamma = [alpha beta];
5 个评论显示 4更早的评论隐藏 4更早的评论
James Tursa 2018-2-5
@ Charles. This comment does not appear to be sufficiently related to the original Question. Suggest you delete this comment and open up a new Question about your specific problem.

更多回答（2 个）

Santiago Alcantara 2022-2-10
Also you can enlarge it the of two. In others words:
you have
alpha = [ 1 2 3 4 5]
alpha = 1×5
1 2 3 4 5
beta = [ 6 7 8 9 10 11 12]
beta = 1×7
6 7 8 9 10 11 12
alpha(6:12)=beta
alpha = 1×12
1 2 3 4 5 6 7 8 9 10 11 12
0 个评论显示 -1更早的评论隐藏 -1更早的评论

Mebin A Abraham 2020-4-14
how can i add elements in an array..... suppose A=[ 1 2 3 4]....i want to get sum of the numbers..ie.1+2+3+4=10.........for that what is the function
1 个评论显示 无隐藏 无
Dinesh Brindavanam 2020-4-18
B = sum(A)

类别

Find more on Numeric Types in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by