prin

Version 1.4 (198 ko) par Paul Mennen
Enhanced formatted IO function (an alternative to sprintf and fprintf)
102 téléchargements
Mise à jour 21 juil. 2021

Afficher la licence

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.

Citation pour cette source

Paul Mennen (2024). prin (https://www.mathworks.com/matlabcentral/fileexchange/60981-prin), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2020a
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Characters and Strings dans Help Center et MATLAB Answers
Tags Ajouter des tags

Community Treasure Hunt

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

Start Hunting!
Version Publié le Notes de version
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