Filter löschen
Filter löschen

Reshape row vector with given number of column

2 Ansichten (letzte 30 Tage)
Dinh Le Dung
Dinh Le Dung am 30 Apr. 2022
Kommentiert: Dinh Le Dung am 1 Mai 2022
I try to turn a row vector into a new vector with a given number of column:
Ex: A = [1,2,3,4,5,6] , col = 3
Output would be
B = [1,2,3;4,5,6]
I try to use "reshape" but the output is [1,3,5;2,4,6] as not what i want

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 30 Apr. 2022
A = [1,2,3,4,5,6] , col = 3
A = 1×6
1 2 3 4 5 6
col = 3
B = reshape(A, col, []).'
B = 2×3
1 2 3 4 5 6

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by