tprintf

バージョン 1.01 (10.3 KB) 作成者: per isakson
tprintf writes tabular data to a text file
ダウンロード: 91
更新 2017/9/13

ライセンスの表示

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

引用

per isakson (2024). tprintf (https://www.mathworks.com/matlabcentral/fileexchange/64390-tprintf), MATLAB Central File Exchange. に取得済み.

MATLAB リリースの互換性
作成: R2016a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersText Files についてさらに検索
タグ タグを追加

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.01

fixed typo
lines added to "Overwiew"

1.0.0.0