How to add elements to the end of an array?

264 visualizaciones (últimos 30 días)
Angela  Albrecht
Angela Albrecht el 27 de Oct. de 2016
Respondida: Santiago Alcantara el 10 de Feb. de 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 comentarios
Image Analyst
Image Analyst el 27 de En. de 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
Punnag Chatterjee el 2 de Feb. de 2018
Thanks for this info.

Iniciar sesión para comentar.

Respuesta aceptada

John Wirzburger
John Wirzburger el 27 de Oct. de 2016
gamma = [alpha beta];
  5 comentarios
suong Tran
suong Tran el 4 de Dic. de 2017
Thank you!
James Tursa
James Tursa el 5 de Feb. de 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.

Iniciar sesión para comentar.

Más respuestas (2)

Santiago Alcantara
Santiago Alcantara el 10 de Feb. de 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

Mebin A Abraham
Mebin A Abraham el 14 de Abr. de 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

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by