prin

バージョン 1.4 (198 KB) 作成者: Paul Mennen
Enhanced formatted IO function (an alternative to sprintf and fprintf)
ダウンロード: 102
更新 2021/7/21

ライセンスの表示

Sprintf, defined by the standard C library, is somewhat mismatched to Matlab, which is a higher level rapid prototyping language compared to the lower level system programming C language. This submission introduces the prin function which includes all the capabilities of sprintf and fprintf while overcoming these shortcomings:
1.) The %f, %e, and %g floating point conversions are adequate for most system programming tasks, but are not flexible enough for graphical programming. The new %w and %v formatting conversions provided by prin avoid most of the limitations of sprintf’s floating point conversions.
2.) It’s difficult to vectorize code containing sprintf because it doesn’t provide an easy way to repeat portions of the format string. For this reason, prin format strings allow two new constructs (repeat counts and vector formats).
3.) Cell arrays of strings are essential in Matlab graphical programming and have other uses as well. Creating these objects is cumbersome with sprintf since it doesn’t allow cell array input or output arguments; prin does not suffer from this limitation.
4.) The imaginary part of complex numbers are ignored when passed to sprintf. With prin, you can use number conversion modifiers to properly format complex numbers.
5.) The [fopen, fprintf, fclose] sequence required to write a simple text file is often cumbersome; prin provides a simpler one-line mechanism for this common task.

引用

Paul Mennen (2024). prin (https://www.mathworks.com/matlabcentral/fileexchange/60981-prin), MATLAB Central File Exchange. 取得済み .

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

Community Treasure Hunt

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

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

Replaced the use of findstr() with strfind() for compatibility with future matlab versions (findstr is being deprecated.) Improved the pdf document file.

1.3

Version 08-Apr-21: Minor documentation improvements

1.2

Fixed minor errors in the documentation pdf file

1.1

I added a new feature to prin called vector pretty printing. See the last two pages of the help file (pdf or odt) for an explanation of the new feature.

1.0.0.0