How to add rows at a specific location

조회 수: 2 (최근 30일)
Tanmoyee Bhattacharya
Tanmoyee Bhattacharya 2015년 5월 21일
편집: Walter Roberson 2015년 5월 21일
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
Nobel Mondal
Nobel Mondal 2015년 5월 21일
Could you please separate the code and filetext from the question statements? It's a bit difficult to understand with everything mixed together.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Standard File Formats에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by