I read in a text file of multiple lines into a cell array (nx1). I manipulate some of the cells. Some of the line in the text file is just an empty line (carriage return). I then write out the cell array into a text file using the code below.
for n = 1:length(cc)
...
dlmwrite(file_3, cc{n}, 'delimiter','','-append');
endThe program work fine except that the empty lines are not writtine in the newly created text fle.
No products are associated with this question.
for n = 1:length(cc)
...
if isempty(cc{n})
fprintf(file_3, '\n');
else
dlmwrite(file_3, cc{n}, 'delimiter','','-append');
end
end
I assume, this would be faster:
fid = fopen(FileName, 'w');
if fid == -1, error('Cannot open file for writing'); end
fprintf(fid, '%s\n', cc{:});
fclose(fid);
0 Comments