フィルターのクリア

To generate a series with n numbers on and n numbers off

1 回表示 (過去 30 日間)
Mukhtiar Ali Unar
Mukhtiar Ali Unar 2022 年 7 月 25 日
コメント済み: Mukhtiar Ali Unar 2022 年 7 月 30 日
I want to generate a series starting with natural number n. First n numbers are retained, next n numbers are removed and so on.
e.g if n is 4 then [4,5,6,7, 12,13,14,15, 20,21,22,23, ....]
similarly if n is 8 then [8,9,10,11,12,13,14,15, 24, 25, 26,27,28,29,30,31,....]
Any help will be appreciated

回答 (2 件)

Chunru
Chunru 2022 年 7 月 25 日
n = 8; xmax=100;
x = (0:n-1)'+(n:n*2:xmax);
x=x(:)
x = 48×1
8 9 10 11 12 13 14 15 24 25

Bruno Luong
Bruno Luong 2022 年 7 月 25 日
n=4;
x=reshape(n+(0:10)*2*n+(0:n-1)',1,[])
x = 1×44
4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31 36 37 38 39 44 45 46 47 52 53 54 55 60 61

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by