How to split a column matrix into N parts

Hi Everyone,
I have a column matrix with dimensions 100000 x 1 and I want to split that column into 100 columns each containing 1000 of the datapoints. Is there a way to go about doing that?
Thank you,
Tyler Seudath

 Accepted Answer

reshape is a great way to do this:
x=rand(100000,1);
y=reshape(x,1000,100);
y1=reshape(x,1000,[]); % Because the 100 is determined, you can let MATLAB calculate it
y2=reshape(x,[],100); % Because the 1000 is determined, you can let MATLAB calculate it
x(1:10)
ans = 10×1
0.1711 0.5883 0.6202 0.0120 0.7058 0.5331 0.6814 0.0042 0.1854 0.1365
x(1001:1010)
ans = 10×1
0.7332 0.6696 0.3997 0.6966 0.6261 0.3499 0.3917 0.6445 0.1319 0.0736
y(1:10,1:2)
ans = 10×2
0.1711 0.7332 0.5883 0.6696 0.6202 0.3997 0.0120 0.6966 0.7058 0.6261 0.5331 0.3499 0.6814 0.3917 0.0042 0.6445 0.1854 0.1319 0.1365 0.0736

More Answers (0)

Categories

Asked:

on 5 Nov 2021

Answered:

on 5 Nov 2021

Community Treasure Hunt

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

Start Hunting!