0
我有一個4×4矩陣像X和一個2×2矩陣狀A.比較相應的塊矩陣元素中的另一矩陣
X= x11 x21 x31 x41 A= 1 0
x12 x22 x32 x42 0 1
x13 x23 x33 x43
x14 x24 x34 x44
我分X四個2×2塊用下面的代碼:
Y=X;
sx=size(X);
mask=logical([1 1;1 1]);
for i=1:2:sx(1)
for j=1:2:sx(2)
px=X(i:i+1,j:j+1);
end
end
現在我要矩陣A的每個元素與矩陣X的相應塊比較
If the first element of matrix A is zero, then x11 should be lower than x22.
if not, I should swap them with each other.
If the first element of matrix A is one ,then x11 should be greater than x22.
if not,I should swap them with each other.