prin

Enhanced formatted IO function (an alternative to sprintf and fprintf)
102 download
Aggiornato 21 lug 2021

Visualizza la licenza

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.

Cita come

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

Compatibilità della release di MATLAB
Creato con R2020a
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su Characters and Strings in Help Center e MATLAB Answers
Tag Aggiungi tag

Community Treasure Hunt

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

Start Hunting!
Versione Pubblicato Note della release
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