フィルターのクリア

how to handle multiple colons

1 回表示 (過去 30 日間)
Reza Teimoori
Reza Teimoori 2016 年 12 月 20 日
編集済み: Stephen23 2016 年 12 月 21 日
The result of [1:101]:0.5:[2:102] in MATLAB is [1 1.5 2] while I'd like to get a vector similar to [1 1.5 2 2 2.5 3 3 3.5 4 4 4.5 5 ... 101 101.5 102]. Does anyone know how I can generate this vector in a single command (ie. no looping)? I'm using MATLAB R2012b. Thanks!

採用された回答

Walter Roberson
Walter Roberson 2016 年 12 月 20 日
reshape( bsxfun(@plus, (1 : 0.5 : 2).', 0 : 100), 1, [])
If you have R2016b or later you can use
reshape( (1 : 0.5 : 2).' + (0:100), 1, [])

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by