output a file text in a uicontrol of style 'static text'

Hallo.
I would like to output a text file in a GUI containg a unique large static text uicontrol (This is meant to be a Help window for another GUI).
I understand that the Text that I want to display should be set as the String property, for example the following code in the CreateFcn callback
Text = 'Hallo world!'
set(hObject,'String',Text)
works fine. But how can I obtain Text from a file which contains (multiline) text? Thanks.

 採用された回答

Jan
Jan 2012 年 2 月 23 日

0 投票

fid = fopen('filename.txt');
if fid < 0, error('Cannot open file'); end
C = textscan(fid, '%s', 'Delimiter', '\n');
fclose(fid);

その他の回答 (2 件)

Guido
Guido 2012 年 2 月 23 日

0 投票

Great, thanks!
Now that it works, I realize that the text is far longer than the Static Text cell, and it is wrapped. Is there a way to have a vertical scrolling bar? If this cannot be done by a Static text uicontrol, is there any other way?
What I have to show is a long, possible changing in time, text file.

1 件のコメント

Jan
Jan 2012 年 2 月 23 日
Try uicontrol('Sytle', 'listbox', 'String', {'1', '2', '3', '4', '5'});

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

Guido
Guido 2012 年 2 月 23 日

0 投票

Perfect! Thanks a lot.

カテゴリ

ヘルプ センター および File ExchangeDesktop についてさらに検索

タグ

質問済み:

2012 年 2 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by