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
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().
Eltigani hamad
Eltigani hamad 2014-12-2
this is an input file for other software i want to link it with matlab so the first input file i would like to delete let say 516, 517. next input file, 514, 515, 516 517 and so on

请先登录,再进行评论。

采纳的回答

Mohammad Abouali
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 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by