Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

matlab

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?

like image 344
Niklas Rosencrantz Avatar asked Nov 27 '22 02:11

Niklas Rosencrantz


2 Answers

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
like image 161
rdurand Avatar answered Dec 10 '22 10:12

rdurand


[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];
like image 26
Andrey Rubshtein Avatar answered Dec 10 '22 08:12

Andrey Rubshtein