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?

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 14 日

0 投票

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

3 件のコメント

Hussain Hayat
Hussain Hayat 2015 年 7 月 15 日
So does this sort of create an empty string before Henry. Why does it add VIII later then?
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 15 日
編集済み: Azzi Abdelmalek 2015 年 7 月 15 日
%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!
Hussain Hayat
Hussain Hayat 2015 年 7 月 15 日
I cant figure out how this function works completely, I did check MATLAB help, hoping that this example can help clear it up.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で File Operations についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by