Fprintf question and application.

fprintf( '%7sVIII\n', 'Henry' )
fprintf( '%1sVIII\n', 'Henry' )
I can't understand the difference between the two. They have the same output. How does the field size value effect the fprintf?

 Accepted Answer

Write this, you will understand
fprintf( '%50sVIII\n', 'Henry' )

3 Comments

So does this sort of create an empty string before Henry. Why does it add VIII later then?
Azzi Abdelmalek
Azzi Abdelmalek on 15 Jul 2015
Edited: Azzi Abdelmalek on 15 Jul 2015
%50s, will be replaced by a string 'henry' with length equal to 50 characters, that's why you 45 blanks and the five character of 'Henry'.
VIII? because you add it!
I cant figure out how this function works completely, I did check MATLAB help, hoping that this example can help clear it up.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Compiler SDK in Help Center and File Exchange

Products

Tags

Community Treasure Hunt

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

Start Hunting!