Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
merge two arrays

Subject: merge two arrays

From: Young Ryu

Date: 15 May, 2008 19:32:01

Message: 1 of 9

Hi-

I have two arrays:
A=
1 2
3 4
5 6

and
B=
7 8
9 10

I tried to merge two arrays like:
C=
1 2
3 4
5 6
7 8
9 10

Is there any simple method for getting C?

Thanks!

Subject: merge two arrays

From: CandyGirl

Date: 15 May, 2008 19:56:17

Message: 2 of 9

If you defined A and B as a matrices you could do it.
i.e :

A=[1,2;3,4;5,6], B=[7,8;9,10], and define C as
C=[A;B]

To be honest, I'm not very familiar with arrays.

sorry ;)

Subject: merge two arrays

From: Jos

Date: 15 May, 2008 20:02:02

Message: 3 of 9

"Young Ryu" <ryuyr77@gmail.com> wrote in message
<g0i33h$ntr$1@fred.mathworks.com>...
> Hi-
>
> I have two arrays:
> A=
> 1 2
> 3 4
> 5 6
>
> and
> B=
> 7 8
> 9 10
>
> I tried to merge two arrays like:
> C=
> 1 2
> 3 4
> 5 6
> 7 8
> 9 10
>
> Is there any simple method for getting C?
>
> Thanks!
>
>
>
>
>

look at

help horzcat

and try things out.

Also the "Getting Started" section might be very useful for
you.

hth
Jos

Subject: merge two arrays

From: aasim Azooz

Date: 16 May, 2008 09:47:10

Message: 4 of 9

"Young Ryu" <ryuyr77@gmail.com> wrote in message
<g0i33h$ntr$1@fred.mathworks.com>...
> Hi-
>
> I have two arrays:
> A=
> 1 2
> 3 4
> 5 6
>
> and
> B=
> 7 8
> 9 10
>
> I tried to merge two arrays like:
> C=
> 1 2
> 3 4
> 5 6
> 7 8
> 9 10
>
> Is there any simple method for getting C?
>
> Thanks!
>
>
>
>
> Try
C=[A,B]

Subject: merge two arrays

From: aasim Azooz

Date: 16 May, 2008 09:47:10

Message: 5 of 9

"Young Ryu" <ryuyr77@gmail.com> wrote in message
<g0i33h$ntr$1@fred.mathworks.com>...
> Hi-
>
> I have two arrays:
> A=
> 1 2
> 3 4
> 5 6
>
> and
> B=
> 7 8
> 9 10
>
> I tried to merge two arrays like:
> C=
> 1 2
> 3 4
> 5 6
> 7 8
> 9 10
>
> Is there any simple method for getting C?
>
> Thanks!
>
>
>
>
> Try
C=[A,B]

Subject: merge two arrays

From: Nitin Chhabra

Date: 16 May, 2008 10:03:01

Message: 6 of 9

"aasim Azooz" <aasimazooz@yahoo.com> wrote in message
<g0jl6u$2n3$1@fred.mathworks.com>...
> "Young Ryu" <ryuyr77@gmail.com> wrote in message
> <g0i33h$ntr$1@fred.mathworks.com>...
> > Hi-
> >
> > I have two arrays:
> > A=
> > 1 2
> > 3 4
> > 5 6
> >
> > and
> > B=
> > 7 8
> > 9 10
> >
> > I tried to merge two arrays like:
> > C=
> > 1 2
> > 3 4
> > 5 6
> > 7 8
> > 9 10
> >
> > Is there any simple method for getting C?
> >
> > Thanks!
> >
> >
> >
> >
> > Try
> C=[A,B]
>

Hi,

C=[A;B] ( [A,B] will put them vertically )

cheers,
Nitin

Subject: merge two arrays

From: Jane

Date: 11 Jul, 2011 22:59:10

Message: 7 of 9

"Young Ryu" wrote in message <g0i33h$ntr$1@fred.mathworks.com>...
> Hi-
>
> I have two arrays:
> A=
> 1 2
> 3 4
> 5 6
>
> and
> B=
> 7 8
> 9 10
>
> I tried to merge two arrays like:
> C=
> 1 2
> 3 4
> 5 6
> 7 8
> 9 10
>
> Is there any simple method for getting C?
>
> Thanks!
>
>
>
>
>
You can also use a built-in matlab function called vertcat (Concatenate arrays vertically).

The syntax given by matlab is:

C = vertcat(A1, A2, ...)

Cheers.

Subject: merge two arrays

From: Yaron

Date: 25 Jun, 2014 07:50:11

Message: 8 of 9

Try : C(:)=[A;B]



"Young Ryu" wrote in message <g0i33h$ntr$1@fred.mathworks.com>...
> Hi-
>
> I have two arrays:
> A=
> 1 2
> 3 4
> 5 6
>
> and
> B=
> 7 8
> 9 10
>
> I tried to merge two arrays like:
> C=
> 1 2
> 3 4
> 5 6
> 7 8
> 9 10
>
> Is there any simple method for getting C?
>
> Thanks!
>
>
>
>
>

Subject: merge two arrays

From: Yaron

Date: 25 Jun, 2014 07:58:09

Message: 9 of 9

"Yaron " <yaron.glazer@ge.com> wrote in message <loduvj$9h5$1@newscl01ah.mathworks.com>...
    
> Try : C=zeros(1,50); C(:)=[A;B]
>
>
>
> "Young Ryu" wrote in message <g0i33h$ntr$1@fred.mathworks.com>...
> > Hi-
> >
> > I have two arrays:
> > A=
> > 1 2
> > 3 4
> > 5 6
> >
> > and
> > B=
> > 7 8
> > 9 10
> >
> > I tried to merge two arrays like:
> > C=
> > 1 2
> > 3 4
> > 5 6
> > 7 8
> > 9 10
> >
> > Is there any simple method for getting C?
> >
> > Thanks!
> >
> >
> >
> >
> >

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us