フィルターのクリア

how to shift arrays to the right??

1 回表示 (過去 30 日間)
mary
mary 2013 年 1 月 21 日
回答済み: Nathan Hall 2022 年 4 月 19 日
for example i have :
arr=[1 0 1 1 0 0 0 1];i want to shift it one step to the right and add a random bit to the left
my array will be ike this arr=[? 1 0 1 1 0 0 0]
?: could be 0 or 1 .
  4 件のコメント
mary
mary 2013 年 1 月 21 日
thanx Mr.Matt it worked
okay Mr.Jan i will consider this note nxt time.
Laeticia Osemeke
Laeticia Osemeke 2020 年 10 月 20 日
How can you do this with a for loop

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

採用された回答

Thorsten
Thorsten 2013 年 1 月 21 日
arr = [round(rand(1,1)) arr];
  1 件のコメント
mary
mary 2013 年 1 月 21 日
okay it worked but didn't delete the shifted bit on the right.. thanx

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

その他の回答 (1 件)

Nathan Hall
Nathan Hall 2022 年 4 月 19 日
arr = [randi([0,1],1),arr(1:end-1)]

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by