如何选择具有特定数量元素的向量?

时间:2018-04-09 15:44:17

标签: list matrix wolfram-mathematica

假设我有以下数据:

k = {{4.27866*10^-13,-1.42199*10^-13,-14.3052},{1.37715*10^-12,1.54405*10^-13,57.2207},{7.5824*10^-13,-6.49694*10^-14,-14.3052},{1.27432*10^-13,5.61507*10^-13,57.2207},{3.70858*10^-14,-7.96837*10^-13,57.2207},{3.92797*10^-13,1.48757*10^-12,-28.6104},{-4.10392*10^-12,-2.73776*10^-12,114.441},{-1.51969*10^-12,1.06176*10^-12,-28.6104},{-4.59286*10^-13,-3.12823*10^-12,57.2207},{1.65875*10^-12,3.0834*10^-12,57.2207},{-3.23525*10^-13,1.71989*10^-12,-28.6104},{3.77647*10^-12,-3.01939*10^-12,114.441},{-1.87065*10^-12,1.24166*10^-12,-28.6104},{-1.943*10^-12,-2.1757*10^-13,57.2207},{8.54924*10^-13,2.33037*10^-13,57.2207},{1.63408*10^-12,-2.67705*10^-12,-28.6104},{-1.70569*10^-13,1.77206*10^-12,114.441},{5.3375*10^-13,1.17943*10^-12,-28.6104},{-1.32554*10^-12,1.54792*10^-12,57.2207},{-8.241*10^-13,-1.40979*10^-12,57.2207},{1.165*10^-12,-5.75912*10^-12,-28.6104},{3.13416*10^-12,5.60966*10^-12,114.441},{1.24376*10^-12,-9.52466*10^-15,-28.6104},{-2.89891*10^-12,2.69403*10^-12,57.2207},{-6.22802*10^-12,-2.64539*10^-12,57.2207},{2.02785*10^-12,1.37895*10^-12,-28.6104},{-4.27374*10^-12,-4.53139*10^-12,114.441},{4.02993*10^-12,3.45467*10^-12,-28.6104},{1.89303*10^-12,-2.42926*10^-12,57.2207},{2.51145*10^-12,2.5046*10^-12,57.2207},{-6.58799*10^-13,2.81488*10^-12,-28.6104},{-1.53405*10^-12,-3.34721*10^-12,114.441},{-5.55037*10^-13,9.55643*10^-13,-28.6104},{2.19236*10^-13,1.23658*10^-12,57.2207},{-9.32115*10^-14,-1.05116*10^-12,57.2207},{-4.8363*10^-13,-2.06515*10^-13,-14.3052},{1.76312*10^-12,-4.42531*10^-13,57.2207},{-6.27983*10^-13,5.71422*10^-13,-14.3052},{-8.74832*10^-29},{-7.24913*10^-29},{3.90609*10^-30},{-6.01168*10^-29},{-2.70339*10^-29},{1.13779*10^-28},{4.72628*10^-30},{-1.08871*10^-28},{-9.79436*10^-29},{-5.84032*10^-29},{-2.15675*10^-28},{-1.76768*10^-28},{-2.68466*10^-28},{-4.23548*10^-28},{-9.12504*10^-29},{-6.79045*10^-29}};

其中有两种类型的列表,一种是3个元素,另一种只有一个元素。问题是如何选择包含3个元素的所有列表?

1 个答案:

答案 0 :(得分:1)

我会使用Cases。以下选项应该有效:

Cases[k,{_,_,_}]

Cases[k,{Repeated[_,{3}]}]