What does the symbol ";" mean in the statement "p1 = [x; y]"?

 Risposta accettata

Hi,
this means x and y are combined vertically to a new vector. So p1 = [x;y] creates a vector
p1 = (x)
(y)
Or simply try it with an example
p1 = [1;2]

3 Commenti

Oh..but if i want to combine them horizontally can i use the following
p=[x y] ??
Horizontal concatenation: [a, b], or [a b] or cat(2, a, b) or horzcat(a, b)
Vertical concatenation: [a; b], cat(1, a, b), vertcat(a, b)
Another method, which is prone to errors is using the line break as separator:
[a
b]

Accedi per commentare.

Più risposte (1)

k.v.swamy
k.v.swamy il 15 Feb 2012
hi, p1 = [x; y]; means u r combining the vectors x and y in to a single vector p1.

Categorie

Richiesto:

il 15 Feb 2012

Modificato:

dpb
il 13 Ott 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by