Filter löschen
Filter löschen

3D Submatrices extraction by indexing the 3rd dimension

2 Ansichten (letzte 30 Tage)
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”.

Akzeptierte Antwort

Stephen23
Stephen23 am 16 Okt. 2023
a_substruct.m1 = a_struct.m(:,:,endsWith(a_struct.i,'1'));
a_substruct.m2 = a_struct.m(:,:,endsWith(a_struct.i,'2'));

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by