How to control reading text character by character
20 views (last 30 days)
Show older comments
Hello Everyone. Can please anyone help me about this? I have a text file here that I've already identified which is 'letterabc.txt' and matlab was able to read it and converted it to binary. The said text file has only "ABC" characters inside. What I want to do is to be able to read the characters letter by letter (A->B->C) in a controlled manner. Like its up to the user when will he or she decides to read the next letter(if button is pressed, the user will be able to read the next letter). The characters are already converted to binary (7bits) so I want to be able to read/display (1000001->1000010->1000011) in a controlled manner.

Accepted Answer
ES
on 2 Aug 2017
fid = fopen('letterabc.txt');
tline = fgetl(fid);
while ischar(tline)
YesOrNo = input('continue Reading [y/n]')
if strcmpi(YesOrNo, 'y')
disp(tline)
tline = fgetl(fid);
else
fclose(fid);
return;
end
end
fclose(fid);
0 Comments
More Answers (0)
See Also
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!