フィルターのクリア

how to apply two statement in if loop?

1 回表示 (過去 30 日間)
Zarak kh
Zarak kh 2019 年 9 月 30 日
回答済み: Andrei Bobrov 2019 年 9 月 30 日
Hello
I have two matrix below:
A= [9 13; 11 9];
B=[12 6; 25 31; 5 13;11 16];
I want to check that if Matrix A is greater than 0 and all elements of matrix A is equal to matrix B and run an if loop. How can I do that in matlab, I have right a code but I think there should be a straightforward solution.
if All elements of A >0 & all elemnts of A is equal to B
do something
end
Thanks in advance.
My code:
A= [9 13; 11 9];
B=[12 6; 25 31; 5 13;11 16]
if A>0 & all(all(ismember(A,B)==1))==0
disp("All the elemnts of A are positive and not equal to B")
end

採用された回答

Andrei Bobrov
Andrei Bobrov 2019 年 9 月 30 日
if all(A(:)>0) & all(ismember(A(:),B(:))==0)
..
end

その他の回答 (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