tprintf

Version 1.01 (10,3 KB) von per isakson
tprintf writes tabular data to a text file
91 Downloads
Aktualisiert 13 Sep 2017

Lizenz anzeigen

tprintf provides an intuitive interface to fprintf for writing tabular data to a text
file. tprintf(filespec,format,A1,...,An) creates a tabular text file by writing the
columns of A1,...,An to columns in the text file.
.
fprintf(fid,format,v1,v2,...), where v1,v2,... are scalars, writes one row. To
print several rows one may put the function in a for-loop. That code is easy to read and
understand. However, with large files speed becomes a problem. fprintf(...,C{:}),
where C is a cell array containing numeric and character data, writes the text file much
faster. With pure numerical data fprintf(...,M), where M is matrix writes even faster.
However, the cell array, C, and the matrix, M, come at a price. It takes some effort to
create them and the resulting code is not all that easy to read and understand - IMO.
With tprintf I try to combined the best of the two.
.
Installation: This submission consists of three m-files and this documentation. Copy the
m-files to a folder on the Matlab search path. Verify that tprintf is working by running
.
>> tprintf( 1, '%d, %4.1f, %s, %s\n', [1;2], rand(2,1),{'first';'second'},['ABC';'DEF'] )
1, 0.6, first, ABC
2, 0.1, second, DEF
ans =
41

Zitieren als

per isakson (2024). tprintf (https://www.mathworks.com/matlabcentral/fileexchange/64390-tprintf), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2016a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
1.01

fixed typo
lines added to "Overwiew"

1.0.0.0