フィルターのクリア

How can I select n rows every m rows

13 ビュー (過去 30 日間)
QuanCCC
QuanCCC 2018 年 8 月 22 日
コメント済み: QuanCCC 2018 年 8 月 23 日
It's a select several rows/extract rows in data question. My data looks like this:
a1 b1 c1
a2 b2 c2
a3 b3 c3
a10 b10 c10
a20 b20 c20
a30 b30 c30
a1 b1 c1
a2 b2 c2
a3 b3 c3
a10 b10 c10
a20 b20 c20
a30 b30 c30
a1 b1 c1
a2 b2 c2
a3 b3 c3
a10 b10 c10
a20 b20 c20
a30 b30 c30
I need to extract into a new data which only includes
a10 b10 c10
a20 b20 c20
a30 b30 c30
a10 b10 c10
a20 b20 c20
a30 b30 c30
a10 b10 c10
a20 b20 c20
a30 b30 c30
How can I do that? Thank you.

採用された回答

Matt J
Matt J 2018 年 8 月 22 日
編集済み: Matt J 2018 年 8 月 22 日
This will work for any m,n.
m=3;
n=3;
e=1:size(yourdata,1);
idx=e( (m+n):(m+n):end ) - (n-1:-1:0).' ;
newdata = yourdata(idx,:);
  1 件のコメント
QuanCCC
QuanCCC 2018 年 8 月 23 日
This is perfect. Thank you so much.

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2018 年 8 月 22 日
編集済み: Matt J 2018 年 8 月 22 日
One way is by downloading MAT2TILES,
A=mat2tiles(yourdata,[3,3]);
newdata=cell2mat(A(2:2:end));
  1 件のコメント
QuanCCC
QuanCCC 2018 年 8 月 22 日
Thank you Matt for editing my question. Now it looks better. But I just happened to give an example of every 3*3 subarray data. The actual data I have is: 27060 lines I don't need, then the next 12 lines I need to select, then the next 27060 lines I don't need, then the 12 lines I need. This doesn't sound like a sub-arrays.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLanguage Fundamentals についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by