How to display constant with caption in separate window

12 ビュー (過去 30 日間)
Yury Infimovsky
Yury Infimovsky 2019 年 6 月 3 日
コメント済み: Yury Infimovsky 2019 年 6 月 3 日
So I have this function:
save('LenaInitial.txt','SaveMatr');
s = dir('LenaInitial.txt');
filesizeini = s.bytes;
And I need to display filesizeini with some caption in separate window. Functions like disp or text are not suitable.
  2 件のコメント
Adam Danz
Adam Danz 2019 年 6 月 3 日
Are you displaying this text in a figure? in the command window? in a text field within an app?
And why aren't disp and text() suitable?
Yury Infimovsky
Yury Infimovsky 2019 年 6 月 3 日
I need to display it in separate window like picture or plot. Not command window. Hence I need something else besides disp(). And text() displays this constant in a window with picture even if I creating new figure.

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

採用された回答

Adam Danz
Adam Danz 2019 年 6 月 3 日
編集済み: Adam Danz 2019 年 6 月 3 日
You can only plot text on axes (not on the figure background). However, the axes can be invisible so it appears as if the text is on the figure. Here's a demo.
fh = figure();
% add axis to bottom, left corner
ah = axes(fh,'position',[0,0,.3,.1]);
% add text
x.bytes = 9000;
filesizeini = s.bytes;
textStr = sprintf('filesize = %d bytes', s.bytes);
text(ah,.2,.2,textStr,'HorizontalAlignment', 'left', 'VerticalAlignment', 'bottom')
% Turn off axis
ah.Visible = 'off';
Note that can combine the last line of code with the axes() line like this :
ah = axes(fh,'position',[0,0,.3,.1],'Visible','off');
  6 件のコメント
Yury Infimovsky
Yury Infimovsky 2019 年 6 月 3 日
Thank you very much! This was helpful
Adam Danz
Adam Danz 2019 年 6 月 3 日
Glad I could help!

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2019 年 6 月 3 日
Do you want to display a small dialog box with the text? If so use the msgbox or uialert functions.
  1 件のコメント
Yury Infimovsky
Yury Infimovsky 2019 年 6 月 3 日
thank you too! I'll be keeping that in mind just in case ;)

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

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by