Un-concatenate a vector to a matrix
Show older comments
Lets say I have a 1x100 vector and I want to split it up into a 10x10 matrix. i.e:
vec1 = [100]
mat1 = [1-10;11-20;21-30; ... ;91-100]
is there a simple command for that?
Answers (2)
Christopher McCausland
on 6 Feb 2023
1 vote
Try this:
% Define vec1:
vec1 = 100;
% Create mat1:
mat1 = reshape(1:vec1, 10, [])' % Reshape into 10 rows.
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!