How to check 0 and 1 at matrix every row and column?

4 ビュー (過去 30 日間)
Md. Mohidul Islam
Md. Mohidul Islam 2022 年 4 月 25 日
コメント済み: Torsten 2022 年 4 月 25 日
matrix can only contain one of the only one in his row and column.
  1 件のコメント
Torsten
Torsten 2022 年 4 月 25 日
If you know that the matrix contains only 0's and 1's, sum the rows and sum the columns. If the result is 1 in each case, return "correct".

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

採用された回答

Torsten
Torsten 2022 年 4 月 25 日
編集済み: Torsten 2022 年 4 月 25 日
[m,n] = size(A);
Sc = sum(A,1);
Sr = sum(A,2);
if (Sc == ones(1,n)) & (Sr == ones(m,1))
disp('Correct')
else
disp('Incorrect')
end
I leave the input-from-keyboard part to you.
  3 件のコメント
Md. Mohidul Islam
Md. Mohidul Islam 2022 年 4 月 25 日
Md. Mohidul Islam
Md. Mohidul Islam 2022 年 4 月 25 日
What is the problem? how to solve this?

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

その他の回答 (1 件)

Md. Mohidul Islam
Md. Mohidul Islam 2022 年 4 月 25 日

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by