How to delete a set of numbers in the end of nth text file ?
1 回表示 (過去 30 日間)
古いコメントを表示
i have part of the following text file
*Nset, nset=RM1STIFF, instance=Part-1-1
13, 14, 533, 534, 535, 536, 537, 661, 662, 663, 664, 665, 666, 667
*Nset, nset=RMSTIFF2, instance=Part-1-1
25, 26, 959, 960, 961, 962, 963, 1087, 1088, 1089, 1090, 1091, 1092, 1093
*Nset, nset=LMSTIFF1, instance=Part-1-1
17, 18, 675, 676, 677, 678, 679, 803, 804, 805, 806, 807, 808, 809
*Nset, nset=LMSTIFF2, instance=Part-1-1
21, 22, 817, 818, 819, 820, 821, 945, 946, 947, 948, 949, 950, 951
*Nset, nset=RSNODES, instance=Part-2-1
8, 9, 12, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352,353, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517
for a specific line i would like to delete set of numbers(2 numbers) and print it to a new file then delete more numbers (4 numbers) and print it to another new file, etc, any help to do that
2 件のコメント
dpb
2014 年 12 月 2 日
Are the numeric values on single record or is the linewrap a figment of the display? Is there some auxiliary data that informs the number of elements in each section?
How do you know which line(s) to modify and which values within the lines to change (and to what)?
Basically, the thing with sequential files is that they're, well, "sequential". Which means basically, start a loop, read a line, process it, write the new line, rinse, and repeat until feof().
採用された回答
Mohammad Abouali
2014 年 12 月 2 日
So read the numbers in an array
numberArray=myreadingfunction(...);
then filter those that you don't want Lets say your condition to delete a number is if it is larger than 500 but smaller than 550.
mask= (numberArray>500 & numberArray<550);
now remove them from number Array:
numberArray=numberArray(~mask);
Now write this to a file.
We don't know what is your criteria to remove a number so that part you would know.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!