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
Cita come
per isakson (2024). tprintf (https://www.mathworks.com/matlabcentral/fileexchange/64390-tprintf), MATLAB Central File Exchange. Recuperato .
Compatibilità della release di MATLAB
Compatibilità della piattaforma
Windows macOS LinuxCategorie
Tag
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.
html/
Versione | Pubblicato | Note della release | |
---|---|---|---|
1.01 | fixed typo
|
|
|
1.0.0.0 |