mat = {{{5.30317257, 1.64842072, 5.0780435, 5.08645518, 6.80648361,
9.43812654, 0.315671743, 7.19423081, 0.975049223,
0.947213129}, {9.56799279, 4.12088242, 0.0471024427, 8.37484587,
7.31955311, 8.74499348, 7.96797637, 4.829391, 8.39345896,
2.31362066}, {2.39440901, 1.24682889, 5.54843565, 5.40543148,
1.269972, 8.77438919, 1.16774949, 8.8872299, 6.19703019,
4.63174218}, {7.16644516, 3.74168636, 9.03911967, 7.53649879,
1.56721927, 9.60236569, 7.87332811, 9.11583843, 1.21852673,
5.24545508}}, {{0.734148305, 0.167195462, 5.68974069, 0.967768794,
1.68875857, 9.44272515, 6.06774672, 4.64820542, 7.34879725,
6.61683716}, {3.42058362, 7.99401634, 9.58063439, 8.18368391,
9.86880635, 6.90737726, 7.68507321, 1.88885883, 0.111209586,
4.57367}, {1.50033317, 4.51845628, 2.77647069, 7.96751817,
1.66934792, 4.44314175, 0.783586119, 9.2791439, 0.828392992,
2.63348224}, {1.32614248, 2.46814055, 4.5997688, 6.29204277,
6.94764656, 7.50456466, 0.586000483, 3.64872235, 0.194444861,
1.47771218}}, {{6.72809349, 7.70202709, 3.53103694, 1.18740102,
1.78920007, 8.12038293, 1.22624538, 5.2674687, 4.77198988,
1.72136709}, {3.8921759, 1.55451977, 1.0386819, 3.17480634,
3.23394573, 9.21023052, 0.031652059, 5.11123699, 0.448259866,
8.39986602}, {3.17510833, 8.14136529, 9.25473649, 0.0384855066,
8.27445843, 7.96464051, 0.116503119, 2.51780465, 2.97853468,
9.6616925}, {5.96828246, 5.1698929, 8.6097764, 7.15809872,
0.706361523, 5.82335169, 8.43562212, 9.75905176, 9.75315902,
4.31765167}}}
Suppose your list of matrices is mat
. Then to remove columns 3, 4, 5 and 9 just do:
mat[[;; , ;; , {3, 4, 5, 9}]] = ## &[];
mat
{{{5.30317257, 1.64842072, 9.43812654, 0.315671743, 7.19423081,
0.947213129}, {9.56799279, 4.12088242, 8.74499348, 7.96797637,
4.829391, 2.31362066}, {2.39440901, 1.24682889, 8.77438919,
1.16774949, 8.8872299, 4.63174218}, {7.16644516, 3.74168636,
9.60236569, 7.87332811, 9.11583843, 5.24545508}}, {{0.734148305,
0.167195462, 9.44272515, 6.06774672, 4.64820542,
6.61683716}, {3.42058362, 7.99401634, 6.90737726, 7.68507321,
1.88885883, 4.57367}, {1.50033317, 4.51845628, 4.44314175,
0.783586119, 9.2791439, 2.63348224}, {1.32614248, 2.46814055,
7.50456466, 0.586000483, 3.64872235, 1.47771218}}, {{6.72809349,
7.70202709, 8.12038293, 1.22624538, 5.2674687,
1.72136709}, {3.8921759, 1.55451977, 9.21023052, 0.031652059,
5.11123699, 8.39986602}, {3.17510833, 8.14136529, 7.96464051,
0.116503119, 2.51780465, 9.6616925}, {5.96828246, 5.1698929,
5.82335169, 8.43562212, 9.75905176, 4.31765167}}}
For the second part, let's first compute the distances and store them in dist
(* Since you've deleted columns 3, 4 and 5, you now have 6, 7, and 8 in their position *)
dist = Apply[EuclideanDistance[{#3, #4, #5}, {0, 0, 0}] &, mat, {2}]
{{11.871598, 12.7783636, 12.5433807, 15.4043251}, {12.1485975,
10.5042848, 10.3178499, 8.3651098}, {9.75656308, 10.5334748,
8.35394588, 14.1530999}}
Now insert the distances for each row at the end of that row:
Transpose[Insert[Transpose[mat[[#]]], dist[[#]], -1]] & /@ Range@Length@mat
{{{5.30317257, 1.64842072, 9.43812654, 0.315671743, 7.19423081,
0.947213129, 11.871598}, {9.56799279, 4.12088242, 8.74499348,
7.96797637, 4.829391, 2.31362066, 12.7783636}, {2.39440901,
1.24682889, 8.77438919, 1.16774949, 8.8872299, 4.63174218,
12.5433807}, {7.16644516, 3.74168636, 9.60236569, 7.87332811,
9.11583843, 5.24545508, 15.4043251}}, {{0.734148305, 0.167195462,
9.44272515, 6.06774672, 4.64820542, 6.61683716,
12.1485975}, {3.42058362, 7.99401634, 6.90737726, 7.68507321,
1.88885883, 4.57367, 10.5042848}, {1.50033317, 4.51845628,
4.44314175, 0.783586119, 9.2791439, 2.63348224,
10.3178499}, {1.32614248, 2.46814055, 7.50456466, 0.586000483,
3.64872235, 1.47771218, 8.3651098}}, {{6.72809349, 7.70202709,
8.12038293, 1.22624538, 5.2674687, 1.72136709,
9.75656308}, {3.8921759, 1.55451977, 9.21023052, 0.031652059,
5.11123699, 8.39986602, 10.5334748}, {3.17510833, 8.14136529,
7.96464051, 0.116503119, 2.51780465, 9.6616925,
8.35394588}, {5.96828246, 5.1698929, 5.82335169, 8.43562212,
9.75905176, 4.31765167, 14.1530999}}}
3 is left as an exercise for the reader.
Select[#,#1[[2]]>10^6&]&/@matrix
. You can useMap
to generalize it on the whole list. $\endgroup$Transpose
. This way the columns will turn into rows and the above method will work again. Note that you will need to transpose the matrix one more time after you finish your procedure. $\endgroup$DeleteCases[matrixlist, x_ /; x[[2]] < 10^6, {2}]
, wherematrixlist
is your list of matrices. $\endgroup$