show content of a txt file in a static text.

2 ビュー (過去 30 日間)
jose bernardo
jose bernardo 2013 年 11 月 16 日
コメント済み: dpb 2013 年 11 月 16 日
I have a file.txt (various lines of strings) and I want that when I push a button "pushbutton1", the content of this file will be show in a static text (text4)
Thanks for your help

採用された回答

dpb
dpb 2013 年 11 月 16 日
Read the file into a character variable and display the variable.
fid = fopen('file.txt', 'r');
c = fread(fid, inf, 'uint8=>char')';
Set the string property in the textbox to c
  2 件のコメント
Walter Roberson
Walter Roberson 2013 年 11 月 16 日
'*char' might be better than 'uint8=>char'
dpb
dpb 2013 年 11 月 16 日
Yeah,...that came from remembering an example in freadf help that I just cut 'n pasted w/o reading other than the size argument.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by