Frandy (view profile)

on 21 Sep 2011
Latest activity Answered by TEJAS N JAYARAM

on 24 Jan 2019

topdawgnate (view profile)

Ok, so how do you place elements of one array into another array, so that they are included in either the beginning of the array or the end of the array?

topdawgnate (view profile)

on 21 Sep 2011
Edited by MathWorks Support Team

MathWorks Support Team (view profile)

on 8 Nov 2018

There are many ways to join elements of two arrays. For example, let’s say you have two 2-by-2 matrices A and B:
A = [1 2; 3 4];
B = [5 6; 7 8];
Then the following commands concatenate B to the end of A horizontally:
H1 = [A B]
H2 = horzcat(A,B)
H3 = cat(2,A,B)
The first argument in the cat function (2) tells it to add B as additional columns of A.
These commands concatenate B to the end of A vertically:
V1 = [A; B]
V2 = vertcat(A,B)
V3 = cat(1,A,B)
The 1 tells cat to add B as additional rows of A.

Gonzalo Mata

Gonzalo Mata (view profile)

on 22 Nov 2018
and wich of them is the faster one?

YU-CHENG HUANG (view profile)

on 29 Sep 2017

just using c = [a , b]
ex: a = [1 2 3] b = [4 5 6] c = [a,b]
--> c = [1 2 3 4 5 6]

TEJAS N JAYARAM (view profile)

on 24 Jan 2019

The best way to do this is by simple concatination and its quite simple.
For example,
say A = [1 2 3 4 5]
and you want to add 6 to array A , you create one array B which stores 6 (B = )
then you can concatinate by using A=[A B]
OUTPUT will be A = [ 1 2 3 4 5 6]