フィルターのクリア

Comparing elements of two matrices

1 回表示 (過去 30 日間)
Gianmarco Azzolin
Gianmarco Azzolin 2020 年 11 月 20 日
編集済み: Setsuna Yuuki. 2020 年 11 月 20 日
Hi, I have two matrices of equal dimensions and I have to compare each one of them, in the sense that the element (1,1) of the first matrix must be compared with all the elements of the second, the same for (1,2) and so on.
The fact is that I have to see if A<B, where A and B are the two matrices, but I have to know not only if (1,1) of A is less than (1,1) of B but also if (1,1) of A is less than (1,2) of B and so on.
Thank you so much

回答 (1 件)

Setsuna Yuuki.
Setsuna Yuuki. 2020 年 11 月 20 日
編集済み: Setsuna Yuuki. 2020 年 11 月 20 日
You should try with loops, conditionals and reshape your matrix .
A = [1 2;3 4];
[r,c] = size[A];
A = reshape(A, [1 r*c]) %with B the same
With A and B (1,r*c) in a loops you can compare with a if
if(A(n) < B(m))
...
end

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by