フィルターのクリア

How to organize large column in to small Commons.

2 ビュー (過去 30 日間)
friet
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 件)

Adam Danz
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.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by