How to organize large column in to small Commons.
1 次查看(过去 30 天)
显示 更早的评论
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,
0 个评论
回答(1 个)
Adam Danz
2018-9-17
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!