Info

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

Changing file name, when fprintf reaches an N number of lines

1 view (last 30 days)
i hope someone can help me, how to achieve this. I have a code that writes permutation to a file. i realized that my output file is very big. i would like to know how to be able to split change the name of the text when a number of lines has been written every time, f.eks, changing the name of the file every written 1000 lines. any help will be appreciated.
my code so far :
fid = fopen( 'file1.txt' );
cac = textscan( fid, '%20s' );
fclose( fid );
num = cac{1};
fid = fopen( 'file2.txt' );
cac = textscan( fid, '%20s' );
fclose( fid );
str = cac{1};
fid = fopen( 'file3.txt', 'w' );
for ii = 1 : length( num )
for jj = 1 : length( str )
fprintf( fid, '%1s - %1s\n', num{ii}, str{jj} );
end
end
fclose( fid );

Answers (0)

Community Treasure Hunt

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

Start Hunting!