Display variable in GUI screen

3 ビュー (過去 30 日間)
Scott
Scott 2014 年 11 月 23 日
回答済み: Geoff Hayes 2014 年 11 月 23 日
I have a function which gets an input from the user title "name". this "name is then passed to another function, which opens a different figure than the first screen, where I want to output "name" on the screen.
I have tried to use:
x = sprintf(' %2d',name);
text(200,300,x,'fontsize',40);
Any ideas for how I can output this variable on my figure screen?

回答 (1 件)

Geoff Hayes
Geoff Hayes 2014 年 11 月 23 日
Scott - if I run your code as
name = 42;
x = sprintf(' %2d',name);
text(200,300,x,'fontsize',40);
then a figure appears with a blank axes, with no text whatsoever. That is because the interval for the x and y axes is [0 1]. If I want to see the number 42, then I have to change the x and y limits (or pan within the axes)
xlim([0 225])
ylim([0 325])
If I run these two statements, then the interval changes for each axes, and 42 appears in the top right corner. If you need to specify which axes to write this text object to, then include the Parent property as
text(200,300,x,'fontsize',40,'Parent',haxes);
where haxes is the handle to the axes that you wish to add the text object to.

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by