## How to repeat the condition for two matrices having different sizes?

さんによって質問されました 2019 年 4 月 25 日

さんによって コメントされました 2019 年 4 月 27 日
Andrei Bobrov

### Andrei Bobrov (view profile)

さんの 回答が採用されました
I have two matrices of two different sizes A (61 x 61 x 1085) & B (61 x 61 x 31)
I apply my conditions to first A(61 x 61 x 31) until it reaches to the size of B.
Now I want to repeat the same conditions for next A (61 x 61 x 32:62) until it reaches to the size of B....and so on...upto A(61 x 61 x 1085).

Jan

### Jan (view profile)

2019 年 4 月 25 日
So you can compare the first block A(:, :, 1:31) with B. You get a logical 3D array as output, which contains a TRUE, if the element is greater. What do you want to do with the result? Do you want an all() or any()? Then how to proceed for the rest of A? 1085 is not a multiple of 31. Please explain exactly, what you want to achieve. The less the readers have to guess, the more likey is a useful answer.

2019 年 4 月 26 日
Dear Jan, my apologies
Actually I want to check if the elements of A are greater than elements in B.
So we can compare the first block A(:, :, 31) with B and get a logical 3D array as output and it stores it in a matrix. Now program should check it for the second block A(:,:,32:63) with B again, and stores it in outputs......and so on..
Result should have the dimension as of A (61,61,1085).
thank you
Andrei Bobrov

### Andrei Bobrov (view profile)

2019 年 4 月 26 日

サインイン to comment.

## 1 件の回答

2019 年 4 月 25 日

### Andrei Bobrov (view profile)

2019 年 4 月 26 日
採用された回答

out = A > B(:,:,mod(0:size(A,3)-1,size(B,3))+1);

#### 3 件のコメント

2019 年 4 月 25 日
Thank you for giving response dear Andrei Bobrov.
It is not helping.
Can we do this without using reshape?
The final result also coming different.
Andrei Bobrov

### Andrei Bobrov (view profile)

2019 年 4 月 25 日
What should be the end result?