フィルターのクリア

How do i get my textbox to display the given value of my variable??

2 ビュー (過去 30 日間)
Sebastian Obwoya
Sebastian Obwoya 2019 年 10 月 2 日
編集済み: the cyclist 2019 年 10 月 4 日
pongAxes = axes('color','black','XLim',[0 100],'YLim',[0 100]),...
annotation('textbox',[0.3,0.8,0.2,0.2],'color','white','dis(score(1))');
score = [0,0];
  4 件のコメント
Sebastian Obwoya
Sebastian Obwoya 2019 年 10 月 3 日
編集済み: Sebastian Obwoya 2019 年 10 月 3 日
I want an annotation. It was actually supposed to be written like:
annotation('textbox',[0.3,0.8,0.2,0.2],'string','(score(1))');
My purpose was to print out the first value (1) of my variable score[0,0] in my gamer, to make a scoreboard.
Rik
Rik 2019 年 10 月 3 日
In that case the sprintf command is what you're looking for, as the cyclist already suggested in his answer. Read the documentation for an overview of all available formatting options.

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

採用された回答

the cyclist
the cyclist 2019 年 10 月 2 日
編集済み: the cyclist 2019 年 10 月 4 日
I'm guesing that
dis(score(1))
is a variable you are trying to display. You need to convert that to a string -- just putting quotes around it won't work, as you have presumably discovered.
Try
sprintf('%8.2f',dis(score(1)))
to show what that string will look like. I'm guessing at the format. You could use '%d' if it is an integer, or try adjust the values I guessed at for a floating point. See the documentation for sprintf for lots of details.
You could also just use
num2str(dis(score(1)))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by