Move logical array by one

2 ビュー (過去 30 日間)
Max Bornemann
Max Bornemann 2019 年 4 月 16 日
コメント済み: Max Bornemann 2019 年 4 月 16 日
Hello,
i have the following logical:
id1=logical([0;0;1;1;1]);
id1
____
false
false
true
true
true
now i am searching for an alternative way to create another logical like:
id2=logical([0;1;1;1;0]);
id2
____
false
true
true
true
false
So every 1(true) from id1 should move one row up in id2 and the last 1(true) from id1 should become false in id2. The amount of "true" (3 in this case) shall be the same in both logicals, just moved by one.
I greatly appreciate any assistance.

採用された回答

Matt J
Matt J 2019 年 4 月 16 日
編集済み: Matt J 2019 年 4 月 16 日
id2=circshift(id1,-1)
  1 件のコメント
Max Bornemann
Max Bornemann 2019 年 4 月 16 日
Thank you Matt J!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by