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

Printable View

- October 1st 2013, 01:37 AMSuvadipMatlab-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 - November 23rd 2013, 11:49 AMDavidBRe: 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. - November 24th 2013, 01:06 PMRebesquesRe: 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]; - November 24th 2013, 06:28 PMDavidBRe: 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.)