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

- Oct 1st 2013, 02: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 - Nov 23rd 2013, 12:49 PMDavidBRe: 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. - Nov 24th 2013, 02: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]; - Nov 24th 2013, 07: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.)