# How to organize large column in to small Commons.

조회 수: 3(최근 30일)
friet 2018년 9월 17일
답변: Adam Danz 2018년 9월 17일
Hello I have a large col vector in matlab with size of ~10000. I would like to cut the col at every 100 point as you see it below separate each col. and save it in separate
a1=[x(1:100)];
a2=[x(101:200)];
a3=[x(201:300)];
a4=[x(301:400)];... and so on.
Z=[a1,a2,a3]
However doing like this will take forever. Is ther anyway to do it in loop. Any help is appreciated.
best,

댓글을 달려면 로그인하십시오.

### 답변(1개)

This requires dynamic variable naming and it's not a good practice. To understand why read this:
Instead, if the length of your vector is a multiple of 100 and your data are numeric, turn your vector into a matrix where each column is your 'a1', 'a2', etc. Here's an example using reshape().
data = rand(10000,1);
dataMat = reshape(data, 100, []);
Your variable a12 is just column 12
dataMat(:,12)
If your data are not all numeric or the length of your vector is not a multiple of 100, describe your dataset and we can work out a solution using cell arrays.

댓글을 달려면 로그인하십시오.

### 범주

Find more on Matrix Indexing 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!