Info

This question is closed. Reopen it to edit or answer.

Importing/copying contents of Multiple text files within a folder to a single text file witout disturbing the format

1 view (last 30 days)
I am a beginner with Matlab and trying to read multiple text files (within a single folder) with mixed contents (both strings and numbers) and with specified formatting. I want to import all the contents (without disturbing the format) of all files sequentially and export/copy to one single text file. Sequentially when I say, Files should be read based on some logic (like latest saved or file name). Can anyone help me please. I tried running the below logic but Its not working d=dir(fullfile('*.dat')); for i=1:length(d) F = fopen('Try.dat','a+'); fprintf(F,'%s\n',i); i=i+1; end

Answers (1)

Image Analyst
Image Analyst on 19 May 2015
See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F Let us know if you still can't figure it out.
  1 Comment
GS
GS on 19 May 2015
Hello, thanks for your response. I had gone through the mentioned example before. It will not be suitable to my problem because of below mentioned reasons * nowhere it is reading all the textfiles in the folder * it is not copying the contents of all textfiles in the folder to a single file Any other suggestions ?

Tags

Community Treasure Hunt

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

Start Hunting!