# How to add elements to the end of an array?

256 visualizzazioni (ultimi 30 giorni)
Angela Albrecht il 27 Ott 2016
Risposto: Santiago Alcantara il 10 Feb 2022
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 CommentiMostra 1 commento meno recenteNascondi 1 commento meno recente
Image Analyst il 27 Gen 2018
Punnag, you can put "Answers" down below in the "Answers" section rather than up here. Though, I doubt there's a need to post a duplicate of the answer down there that was already posted 4 months ago.
Punnag Chatterjee il 2 Feb 2018
Thanks for this info.

Accedi per commentare.

### Risposta accettata

John Wirzburger il 27 Ott 2016
gamma = [alpha beta];
##### 5 CommentiMostra 3 commenti meno recentiNascondi 3 commenti meno recenti
suong Tran il 4 Dic 2017
Thank you!
James Tursa il 5 Feb 2018
@ 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.

Accedi per commentare.

### Più risposte (2)

Santiago Alcantara il 10 Feb 2022
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 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Mebin A Abraham il 14 Apr 2020
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 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Dinesh Brindavanam il 18 Apr 2020
B = sum(A)

Accedi per commentare.

### Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by