MATLAB: Show content of a txt file in a static text.

show txt static text

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

Best Answer

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