How to Keep a Character in A Fixed Position?

3 ビュー (過去 30 日間)
Rightia Rollmann
Rightia Rollmann 2017 年 3 月 17 日
編集済み: Chad Greene 2017 年 3 月 17 日
I have created a Static Text that shows the current values of A and B:
A: 1 B: 2
When A’s value has more than one digit, it pushes B forward, and therefore B is no longer in its previous location:
A: 1234567 B: 2
Is there any trick to hold B in a fixed position regardless of the number of A’s digits? So it would like that:
A: 1 B: 2
A: 1234567 B: 2

回答 (1 件)

Chad Greene
Chad Greene 2017 年 3 月 17 日
編集済み: Chad Greene 2017 年 3 月 17 日
Try this:
A = 1;
sprintf('% 8d',A)
B = 1234567;
sprintf('% 8d',B)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by