Convert a Column Vector to Matrix

조회 수: 74 (최근 30일)
Vikram Mohan
Vikram Mohan 2022년 4월 22일
답변: Bruno Luong 2022년 4월 22일
I have a column vector y such that
x = [1 2 3 4 5 6]
y = x'
I would like to change y into a matrix such that the first row contains the values 1 and 2. The second row contains the value 3 and 4. And finally, the last row contains 5 and 6. How can I do this?

답변 (2개)

David Hill
David Hill 2022년 4월 22일
y=reshape(x,2,[])';

Bruno Luong
Bruno Luong 2022년 4월 22일
x = [1 2 3 4 5 6]
x = 1×6
1 2 3 4 5 6
y = reshape(x, 2, [])'
y = 3×2
1 2 3 4 5 6

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by