Check the flipped of 3D Array matrix

1 回表示 (過去 30 日間)
Trang Hu Jia
Trang Hu Jia 2022 年 2 月 16 日
コメント済み: Trang Hu Jia 2022 年 2 月 17 日
Hello everyone,
I'm construct the multi dimensions 3D [X,Y,Z double] matrix.
Suppose I have
A = zeros(3,6,3);
A(:,:,1) = [1 2 3 3 2 1
2 2 3 3 2 2
3 3 4 4 3 3];
A(:,:,2) = [1 1 3 3 1 1
0 0 3 3 0 0
5 5 6 6 5 5];
A(:,:,3) = [0 0 3 3 0 0
1 1 3 3 1 1
5 5 1 1 5 5];
As we can see, along through Z-axis ( the center in column 1 to column 3 can be flipped as column 4 to 6
Do we have any way to check and return as logical value (0,1) to show this multidimension arrays are fliped or not.
Thanks in advances.
  2 件のコメント
Benjamin Thompson
Benjamin Thompson 2022 年 2 月 16 日
Can you define what "flipped" means? You can review the contents of your matrix in MATLAB after creating it.
Trang Hu Jia
Trang Hu Jia 2022 年 2 月 16 日
Thek you very much for replying this topic.
The "flipped" that I mean is in page 1 to 3 (in Z-axis)
Column 3 are exactly the same in column 4, Column 2 are exactly the same in column 5 and so on.
This matrix I can directly check it easily.
However, suppose I have larger matrix in X rows and Y columns, do we have any way to check it by logical ?
Thanks in advances.

サインインしてコメントする。

採用された回答

Jan
Jan 2022 年 2 月 16 日
編集済み: Jan 2022 年 2 月 16 日
Do you mean:
isequal(A, flip(A, 2))
If A is huge (e.g. 1 GB), this operation is not efficient, because it duplicates the Array. If this is the bottleneck of you code, you could to the comparison in a C-mex function. This will be a little bit slower for small A (I estimate until 1000 elements), but much faster if e.g. the first element does not match already and the function can reply FALSE soon.
Do you need such a C-mex function?
  1 件のコメント
Trang Hu Jia
Trang Hu Jia 2022 年 2 月 17 日
Dear @Jan
Thank you for your replying.
This help me a lot.
Thank you very much.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by