MATLAB: How to print large amounts of text to a .txt file

formatspecfprintf

I have written a program that calculates a large array and then inputs those values into a large string and then export to a .txt file. Exporting to the file works fine. A large amount of text is missing from this file however.
here is a general overview of the code I use:
iterations = 3;
&nbsp for iteration = 1:iterations
&nbsp (calculations)
&nbsp&nbsp (array)
&nbsp&nbsp textFileName = ['drivetrain' num2str(iteration) '.txt'];
&nbsp&nbsp fileID = fopen(textFileName,'w');
&nbsp&nbsp formatSpec = 'largestringpart2';
&nbsp&nbsp fprintf(fileID, 'largestringpart1');
&nbsp&nbsp fprintf(fileID, formatSpec,array);
&nbsp&nbsp fclose(fileID);
&nbsp end
this program creates 3 files with 'largestringpart1' cut off after about 210,000 columns, it's total length is about 450,000 columns long. The part in formatSpec prints fine after that.
I get a warning in the line with 'largestringpart1' stating: Warning: Valid octal digits are 0-7.
What does this mean and how can I work around this warning?
I also tried putting the whole string in formatSpec but then it also cuts off after about 210,000 columns.
Another thing I tried was to cut up the whole string and use several fprintf commands but that didn't work either.
Is there any way to have formatSpec print longer strings or for fprintf to print more than 210,000 colums?

Best Answer

Sounds strange. Perhaps try fwrite() rather than fprintf().