Problem reading a text from a text file?

1 view (last 30 days)
I have problem reading a text from a text file and I got this result as showen in the figure.
I could not get the text inside the text file and this is my code .The code is about importing the file and save it and read it.But the reading is not working.
Could you help me please?
[filename,pathname] = uigetfile({'*.txt'},'File Selector');
app.WordFileEditField.Value = strcat(pathname,filename);
save (filename);
fileID = fopen (filename,"rt");
if fileID < 0
error('error opning file %s/n/n',filename)
end
tline = fgets(fileID);
while ischar (tline)
fprintf('%s',tline)
tline = fgets(fileID);
end
fprintf('/n');
fclose(fileID);
app.UIFigure.Visible = 'off';
app.UIFigure.Visible = 'on';

Answers (0)

Community Treasure Hunt

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

Start Hunting!