– Hope to categorize the matrix into number of 2D submatrices, with respect to elements of 6th and 7th column.
– Given matrix A is 2900 x 7 size, contains
[x_coordinate y_coordinate z_coordinate strain_energy atom_index x_category y_category].
Each line contains the information of each 2900 atoms. x_category is the column contains the numbers 1~20, y_category is the column contains the numbers 1~17
All columns contains the numbers.
Hope to change this
submatrix (1,1) = [x_coordinate y_coordinate z_coordinate strain_energy atom_index 1 1]
submatrix (1,2) = [x_coordinate y_coordinate z_coordinate strain_energy atom_index 1 2]
…
submatrix (20,17) = [x_coordinate y_coordinate z_coordinate strain_energy atom_index 20 17]
Number of rows of each submatrices differs, because
I've tried to use double for loop, but does not work.
for i = 1:20
for j = 1:17 submatrix_('i','j') = A(x_category==i & y_category==j,:); end endBut it is not workin...
Is there any way to split matrix into submatrices with specific conditions?
Best Answer