Niklas Rosencrantz
Niklas Rosencrantz

Reputation: 26652

What does A=[x; y'] in Matlab mean?

I'm learning Matlab and I see a line that I don't understand:

A=[x; y']

What does it mean? ' usually means the transponate but I don't know what ; means in the vector. Can you help me?

Upvotes: 4

Views: 22228

Answers (6)

Edric
Edric

Reputation: 25140

Just to be clear, in MATLAB ' is the complex conjugate transpose. If you want the non-conjugating transpose, you should use .'.

Upvotes: 6

Kadiam
Kadiam

Reputation: 401

The semicolon ' ; ' is used to start a new row.

e.g. x=[1 2 3; 4 5 6; 7 8 9] means

    x= 1 2 3 
       4 5 6
       7 8 9

So if u take x=[1 2 3; 4 5 6] and y=[7 8 9]'

then z=[x; y'] means

    z= 1 2 3 
       4 5 6
       7 8 9

Upvotes: 3

mathematician1975
mathematician1975

Reputation: 21351

It indicates the end of a row when creating a matrix from other matrices.

For example

X = [1 2];
Y = [3,4]';
A = [X; Y'] 

gives a matrix

A = [ 1 2 ]
    [ 3 4 ]

This is called vertical concatenation which basically means forming a matrix in row by row fashion from other matrices (like the example above). And yes you are right about ' indicating the transpose operator. As another example you could use it to create a transposed vector as follows

Y = [1 2 3 4 5];
X = [1; 2; 3; 4; 5];
Y = Y';

Comparing the above you will see that X is now equal to Y. Hope this helps.

Upvotes: 4

rdurand
rdurand

Reputation: 7410

The [ ] indicates create a matrix.
The ; indicates that the first vector is on the first line, and that the second one is on the second line.
The ' indicates the transponate.
Exemple :

>> x = [1,2,3,4]
x = 
    1 2 3 4

>> y = [5;6;7;8]
y =
    5
    6
    7
    8

>> y'
ans =
    5 6 7 8

>> A = [x;y']
A = 
    1 2 3 4
    5 6 7 8

Upvotes: 12

Bentoy13
Bentoy13

Reputation: 4956

Let set the size of x m*n (m rows and n columns) and the size of y n*p. Then A is the matrix formed by the vertical concatenation of x and the transpose of y (operator '), and its size is (m+p)*n. The horizontal concatenation is done with comma instead of semi-column. This notation is a nice shorthand for function vertcat. See http://www.mathworks.fr/help/techdoc/math/f1-84864.html for more information

Upvotes: 3

Andrey Rubshtein
Andrey Rubshtein

Reputation: 20915

[x y] means horizontal cat of the vectors, while [x;y] means vertical.

For example (Horizontal cat):

x = [1
     2
     3];

y = [4 
     5 
     6];

[x y] =  [1 4
          2 5 
          3 6];

(Vertical cat):

  x = [1 2 3];
  y = [4 5 6];

 [x; y] = 
      [1 2 3;
       4 5 6];

Upvotes: 7

Related Questions