Stack a certain vectors of a matrix vertically

21 Ansichten (letzte 30 Tage)
Niveen El Zayat
Niveen El Zayat am 14 Jun. 2018
Kommentiert: Niveen El Zayat am 14 Jun. 2018
I have a hypothetical matrix say a =
1 2 3
2 4 5
3 5 6
in one command, how I can stack the first two columns vertically to have a=[1 2 3 2 4 5]'
  3 Kommentare
the cyclist
the cyclist am 14 Jun. 2018
You could make this an answer (rather than a comment on the question).
Niveen El Zayat
Niveen El Zayat am 14 Jun. 2018
I left it as a comment because i am not quite satisfied with this answer, I leave the space to some one give me a more generic answer fit any dimension

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Guillaume
Guillaume am 14 Jun. 2018
Bearbeitet: Guillaume am 14 Jun. 2018
As you've figured out for a 3xN matrix, a(1:6)' would work. For an arbitrary sized MxN matrix:
reshape(a(:, 1:2), [], 1)
  1 Kommentar
Niveen El Zayat
Niveen El Zayat am 14 Jun. 2018
thanks, this is the answer I was looking for, because the above one is very simple hypothetical example my main code is in terms of large dimension and i did try the reshape command but i failed many time

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by