How can I add a line in the text file??

18 visualizaciones (últimos 30 días)
MU SONG LEE
MU SONG LEE el 6 de Sept. de 2017
Respondida: Amy el 8 de Sept. de 2017
I want put a line in my text file.
for example) i have test.txt file.
that's contents
"a b c d e f "
then, I want to add "g h i" under the "d e f"
how can i do this?
my english is not good. sorry

Respuestas (1)

Amy
Amy el 8 de Sept. de 2017
You want to use the fprintf function. See the documentation for it here: https://www.mathworks.com/help/matlab/ref/fprintf.html
The documentation contains information on how to format your output using formatSpec. In your case, you can specify the field width to ensure 'g h i' lines up with 'd e f'. A new line is a special character represented by '\n'. You might also find the example Write Tabular Data to Text File helpful.

Categorías

Más información sobre 셀형 배열 en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!