필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

how to cobine different text files with different contents ?

조회 수: 2 (최근 30일)
shabnam sh
shabnam sh 2019년 2월 23일
마감: MATLAB Answer Bot 2021년 8월 20일
hello everyone ,
I have a question about merging 3 different text file ,
they have different contents , the first one contains : lots of intiger numbers , lots of float numbers and stirngs
"1 226.870000 244.240000 74.970000 89.750000 stop"
the second one contains lots of intiger and lots of float numbers :
"1 134.000000 185.000000 271.528473 207.638260 -0.899857"
the tird one contains lots of strings
"seen"
now i want the output text file to be lke this :
" 1 226.870000 244.240000 74.970000 89.750000 stop 134.000000 185.000000 271.528473 207.638260 -0.899857 seen "
does anyone know what to do this ?
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 2월 23일
Does the third one contain the leading 1 like the other two do?
Does the leading integer on the two files always indicate a match? So the line starting with 692 in the first file is to be matched with the line starting with 692 in the second file, even if the two files are in different orders? Or would it be the case that the 692'nd line of the first file should be matched with the 692'nd line of the second file, even if the two had different integers?

답변 (1개)

Krishna Zanwar
Krishna Zanwar 2019년 2월 27일
Hey Shabnam,
You can get the line as an input using the function fgetl, it will take all the values in a line regardless of the datatypes.
tline = fgetl(fileID);
And you can print the whole line to a new document using the function fprintf.
fprintf(fileId,tline);
Hope this helps.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by