Problem with fprintf function

1 回表示 (過去 30 日間)
Aftab Ahmed Khan
Aftab Ahmed Khan 2015 年 10 月 26 日
コメント済み: Star Strider 2015 年 10 月 26 日
Hi, This is my command window. The second last column of "bnum" is a bit inward in the middle. I don't know how to make it exactly align with upper section of the same column. I use this line of code to achieve this. Any help guys ?
fprintf('C.T = %d:%d\t\t Lambda = %d\t\t OT = %.2f Gbps\t\t snum = %d\t\t pnum = %d\t\t bnum = %d\t\t S.T = %.2f sec.\n',clk_time(4),clk_time(5),ilambda,now_offer_traffic,snum,pnum,bnum,timenow);

採用された回答

Star Strider
Star Strider 2015 年 10 月 26 日
It’s a bit difficult to read, but it’s generally best to assign a fixed-width field if you know the maximum width, rather than using the default width.
I would change the ‘pnum’ format to:
pnum = %4d
or even a wider field if ‘pnum’ will have more than 4 digits. It might be worth setting all the other fields to the widest (longest) you expect them to be in order to keep the columns aligned.
  4 件のコメント
Aftab Ahmed Khan
Aftab Ahmed Khan 2015 年 10 月 26 日
Yup, it is going nice. I got my first paper published last month.
After my few research group fellows, its you who helped me in my work. I really appreciate it.
Thank you.
Star Strider
Star Strider 2015 年 10 月 26 日
Congratulations!
As always, my pleasure. There are a reasonable frequency of communications-related questions here, including network utilisation. I encourage you to Answer them when you have the time.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by