フィルターのクリア

How to shuffle two vectors?

1 回表示 (過去 30 日間)
Mr M.
Mr M. 2018 年 4 月 17 日
編集済み: James Tursa 2018 年 4 月 17 日
I have for example:
V1 = [1 2 3 4 5 16 17 18 19 20];
V2 = [21 20 19 18 17 4 3 2 1 0];
and
flip = [1 0 0 1 1 1 0 1 0 0];
I would like to generate W1 and W2, where W1(i) = V1(i) if flip(i) = 0, but = V2(i) if flip(i) = 1. And W2 has to be the complementer of W1.

採用された回答

Guillaume
Guillaume 2018 年 4 月 17 日
W1 = V1 .* flip + V2 .* ~flip
W2 = V1 .* ~flip + V2 .* flip

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by