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.