フィルターのクリア

Delete rows from array

3 ビュー (過去 30 日間)
ariane
ariane 2018 年 8 月 13 日
コメント済み: ariane 2018 年 8 月 13 日
I have a large csv file which looks like this:
"Ion N","Mass","Charge","X","Y","Z","Azm","Elv","KE"
3849094,0.00054858,-1,66.5216,-51,-3.8,-180,88.7,18160
3849095,0.00054858,-1,27.3925,30.3532,-4.07076,-177.1,41.5494,17697.2
3849096,0.00054858,-1,66.5216,-51,-3.7,-180,88.7,18160
3849097,0.00054858,-1,26.6277,31.0039,-3.91402,-177.096,40.8293,17699.4
3849098,0.00054858,-1,66.5216,-51,-3.6,-180,88.7,18160
3849099,0.00054858,-1,4.125,44.9887,-2.47517,-176.363,25.715,17711.1
To create and array with each second row I use the following command:
data(2:2:end,:) = []
My output file then looks like this:
"Ion N","Mass","Charge","X","Y","Z","Azm","Elv","KE"
3849095,0.00054858,-1,27.3925,30.3532,-4.07076,-177.1,41.5494,17697.2
3849097,0.00054858,-1,26.6277,31.0039,-3.91402,-177.096,40.8293,17699.4
3849099,0.00054858,-1,4.125,44.9887,-2.47517,-176.363,25.715,17711.1
However, I wish to keep the first row and delete the second one and keep the third row and so on but the following command doesn't seem to work.
data(1:1:end, :) = []
My desired output file should look like this:
"Ion N","Mass","Charge","X","Y","Z","Azm","Elv","KE"
3849094,0.00054858,-1,66.5216,-51,-3.8,-180,88.7,18160
3849096,0.00054858,-1,66.5216,-51,-3.7,-180,88.7,18160
3849098,0.00054858,-1,66.5216,-51,-3.6,-180,88.7,18160
Could anyone advise on how I can implement this?

採用された回答

Adam Danz
Adam Danz 2018 年 8 月 13 日
I'm not following your examples but does this solve your problem?
data(1:2:end, :) = []
or
data(2:2:end, :) = []
  1 件のコメント
ariane
ariane 2018 年 8 月 13 日
yup, the first answer solves it. thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by