How to add rows at a specific location

2 Ansichten (letzte 30 Tage)
Tanmoyee Bhattacharya
Tanmoyee Bhattacharya am 21 Mai 2015
Bearbeitet: Walter Roberson am 21 Mai 2015
I have a text file like this
1 2 0
30 0.7646 0.150 0.400 0.350 0.600 1.000 0.000
34 0.2354 0.150 0.000 0.350 0.000 1.000 0.000
79 79 79 10 10 10 12 12 10 10 10 10
1 2 1
30 0.7646 0.150 0.400 0.350 0.600 1.000 0.000
34 0.2354 0.150 0.000 0.350 0.000 1.000 0.000
79 79 79 10 10 10 12 12 10 10 10 10
I have a second text file like this
30
31
32
My question is
if the value of first text file matches with value of first column of secong text file then in fist text file where first row third column is 1 (1 2 1) there the line 30 0.7646 0.150 0.400 0.350 0.600 1.000 0.000(because 30 is matching) will add before the last line like 79 79 79 10 10 10 12 12 10 10 10 10
The final text file will be
1 2 0
30 0.7646 0.150 0.400 0.350 0.600 1.000 0.000
34 0.2354 0.150 0.000 0.350 0.000 1.000 0.000
79 79 79 10 10 10 12 12 10 10 10 10
1 2 1
30 0.7646 0.150 0.400 0.350 0.600 1.000 0.000
34 0.2354 0.150 0.000 0.350 0.000 1.000 0.000
30 0.7646 0.150 0.400 0.350 0.600 1.000 0.000
79 79 79 10 10 10 12 12 10 10 10 10
  1 Kommentar
Nobel Mondal
Nobel Mondal am 21 Mai 2015
Could you please separate the code and filetext from the question statements? It's a bit difficult to understand with everything mixed together.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Standard File Formats finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by