How do I create multiple column vectors from one big column vector?

6 views (last 30 days)
Chad on 24 Mar 2020
Commented: Adam Danz on 25 Mar 2020
I have two column vectors, objx and objy, both of which contain 20,160 floats. I need to dice it up every 48 iterations to create voronoi figures. There will be 420 voronoi diagrams. How do I go about creating smaller vectors each of which containg 48 floats each to create these voronoi diagrams?
Adam Danz
Adam Danz on 24 Mar 2020
That's clear. The comma in 20,160 threw me off. There's no need to use a comma unless the number of digits is very large.

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 24 Mar 2020
Edited: Ameer Hamza on 24 Mar 2020
Try this
X = reshape(objx, 48, 420); % X is 48*420
Y = reshape(objy, 48, 420); % Y is 48*420
% loop will run 420 times
for i=1:size(X,2)
x = X(:,i); % x is 48*1
y = Y(:,i); % y is 48*1
% save the voronoi diagram
Adam Danz
Adam Danz on 25 Mar 2020
That's true; a col or row vector will result in the same reshape. My mind may have still been on the possibility of cell arrays converted to matrices.

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!