how to shift arrays to the right??

1 次查看(过去 30 天)
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 个)

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

类别

Help CenterFile Exchange 中查找有关 Clocks and Timers 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by