How to add rows at a specific location

1 view (last 30 days)
Tanmoyee Bhattacharya
Tanmoyee Bhattacharya on 21 May 2015
Edited: Walter Roberson on 21 May 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 Comment
Nobel Mondal
Nobel Mondal on 21 May 2015
Could you please separate the code and filetext from the question statements? It's a bit difficult to understand with everything mixed together.

Sign in to comment.

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!