Convert a Column Vector to Matrix
显示 更早的评论
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
2022-4-22
y=reshape(x,2,[])';
x = [1 2 3 4 5 6]
y = reshape(x, 2, [])'
类别
在 帮助中心 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!