Results 1 to 4 of 4

Thread: Matlab-Matrix concatenation

  1. #1
    Member
    Joined
    Feb 2010
    Posts
    107

    Matlab-Matrix concatenation

    A=[1 1 1 1 1 1 1 ]
    B=[9 9 9 9 ]

    How to concatenates A and B so that the output becomes

    C=
    1 1 1 1 1 1 1
    - - - 9 9 9 9
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    Sep 2006
    From
    Between my ears
    Posts
    87
    Thanks
    14

    Re: Matlab-Matrix concatenation

    I believe it is just C = [A B]

    This creates C as a one-row matrix, with the entries of B appended behind the entries of A.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Super Member Rebesques's Avatar
    Joined
    Jul 2005
    From
    My house.
    Posts
    649
    Thanks
    40

    Re: Matlab-Matrix concatenation

    first of all, make B have equal length to A, by assigning zeroes in the additional entries: B=[zeros(1,length(A)-length(B)) B];

    then, concate with a semicolon: C=[A;B];
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Member
    Joined
    Sep 2006
    From
    Between my ears
    Posts
    87
    Thanks
    14

    Re: Matlab-Matrix concatenation

    Doesn't that create a matrix with two rows of 7 columns each?

    I read the OP's question as just wanting to append four 9's to the 1-row array, but leave it a single row array.

    (Hmmnn... maybe I misunderstood the OP's request. Although, if we read the question literally, he also wants the first three outputs of the second row to be dashes.)
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Inductive definition of string concatenation?
    Posted in the Discrete Math Forum
    Replies: 8
    Last Post: Sep 12th 2011, 08:29 AM
  2. Concatenation Sequences
    Posted in the Math Forum
    Replies: 0
    Last Post: Jul 3rd 2010, 08:42 AM
  3. Replies: 2
    Last Post: Jan 29th 2010, 05:48 AM
  4. Matlab ( Matrix )
    Posted in the Math Software Forum
    Replies: 2
    Last Post: Apr 6th 2009, 12:32 AM
  5. Matlab help ........Matrix
    Posted in the Math Software Forum
    Replies: 0
    Last Post: Apr 4th 2009, 05:05 AM

Search Tags


/mathhelpforum @mathhelpforum