Addition of two unequal matrices

1 回表示 (過去 30 日間)
adnan saeed
adnan saeed 2018 年 10 月 9 日
コメント済み: M 2018 年 10 月 10 日
I have two matrices of binary variables, e.g A = [1 0;1 1;0 1] and B = [1;0;1].My first question is how to add these matrices, and the other question is I want to apply this statement on the result: A + B <=1. Thanks
  3 件のコメント
adnan saeed
adnan saeed 2018 年 10 月 10 日
I know, but I want to add zeros to the the remaining position and add these two matrices.
M
M 2018 年 10 月 10 日
add zeros to the the remaining position
Can you explain what you mean exactly?

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

回答 (2 件)

KSSV
KSSV 2018 年 10 月 9 日
A = [1 0;1 1;0 1]
B = [1;0;1]
idx = A+B<=1

M
M 2018 年 10 月 9 日
編集済み: M 2018 年 10 月 9 日
You cannot compute A+B. You can only compute the sum for each column:
A+B
ans =
2 1
1 1
1 2

カテゴリ

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