prin

版本 1.4 (198.2 KB) 作者: Paul Mennen
Enhanced formatted IO function (an alternative to sprintf and fprintf)
102.0 次下载
更新时间 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 CenterMATLAB Answers 中查找有关 Characters 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