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 CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by