3D Submatrices extraction by indexing the 3rd dimension

1 回表示 (過去 30 日間)
julian gaviria
julian gaviria 2023 年 10 月 16 日
コメント済み: julian gaviria 2023 年 10 月 16 日
I have a structure array (a_struct) with 2 fields:
a_struct.m= 370x690x109 double
a_struct.i= 109x1 cell. Each cell contains 13 characters, and some of them end with “1” or “2” (e.g., subj01-XXXXt1… subj01-XXXXt2… subj12-XXXXt1, subj12-XXXXt2).
How can I extract two submatrices from “a_struct.m” based on the elements of the third dimension of “a_struct.m (z= 109)” indexed by the last two elements (i.e., “1”, “2”) of the contents of the first dimension of “a_struct.i (x= 109)”? I expect to get something like:
a_substruct.m1= 370x690x30 double
a_substruct.m2= 370x690x40 double
Where the content of “a_substruct.m1” “a_substruct.m2” has been indexed by “a_struct.i”.

採用された回答

Stephen23
Stephen23 2023 年 10 月 16 日
a_substruct.m1 = a_struct.m(:,:,endsWith(a_struct.i,'1'));
a_substruct.m2 = a_struct.m(:,:,endsWith(a_struct.i,'2'));
  1 件のコメント
julian gaviria
julian gaviria 2023 年 10 月 16 日
It worked perfectly. Thank you very much.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by