matlab - 在特定列

时间:2017-06-08 03:56:47

标签: matlab

我的数据结构如下

3159,417.236206055,300.815246582,264.060791016,341.630493164,7.86748231008e-06,2
3159,134.812591553,184.91859436,531.439208984,269.763793945,4.9377590905e-07,2
3159,760.162597656,166.481231689,476.437255859,468.503387451,2.78121348174e-07,2
3159,551.595581055,74.2536621094,479.859985352,303.471374512,1.48180667736e-07,2
3159,1065.83898926,314.981079102,204.258789062,326.364746094,8.80023665051e-08,2
3159,248.040405273,21.629524231,829.945678711,138.450164795,1.37097971864e-08,2
3159,80.3406066895,28.684425354,386.45324707,143.023040771,4.562183617e-09,2
3159,947.76953125,31.7755508423,305.259033203,202.499755859,3.76411957159e-09,2
3159,358.889862061,47.3729171753,382.564605713,221.994903564,1.59999635069e-09,2
3159,1078.03979492,99.2788238525,186.233398438,341.675964355,5.5474613618e-10,2
1,387.461395264,272.173980713,43.5688476562,63.8592529297,0.108503072988,3
1,152.127593994,277.128143311,64.2265625,44.8813476562,0.0766168581322,3
1,226.51335144,153.107879639,31.1640167236,43.1790161133,0.0501157774124,3
1,247.809906006,180.634460449,24.0384521484,21.3278198242,0.0226649455726,3
1,518.350952148,446.070495605,71.6326904297,71.5654296875,0.0222841088544,3
1,506.014434814,452.800079346,38.2752990723,80.2373962402,0.00226600914175,3
1,421.329223633,201.027603149,32.4918823242,24.7145996094,0.000995551727101,3
1,253.987335205,195.959823608,21.352722168,17.3350830078,0.000434513503933,3
1,375.351654053,180.608520508,29.7174682617,29.6880187988,7.9327679714e-05,3
1,194.039138794,145.845596313,40.6948547363,49.4976196289,5.12218832682e-05,3
1,416.31741333,157.50378418,26.3580932617,25.781036377,3.00556763477e-05,3
1,251.972137451,163.274612427,19.8468017578,25.6938781738,2.31373164183e-05,3
1,403.309234619,160.924667358,24.6165771484,22.4505004883,1.56914580884e-05,3
1,385.329711914,156.467712402,17.0793457031,17.9400939941,4.03955411343e-06,3

现在我需要遍历column7,这是2,3,...并计算过滤掉其他(ex: just keep row contain 2 in columns for a iteration) 现在我的解决方案是遍历整个文件。但是我的文件很大,需要花费很多时间。有没有更聪明的方法呢?

1 个答案:

答案 0 :(得分:1)

数据成为您从txst文件读取/加载的矩阵。要选择第7列中包含2的行,您可以执行以下操作:

col7 = data(:,7) ;
idx = col7==2 ;
iwant = data(idx,:) ;