How to control reading text character by character

20 views (last 30 days)
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.
  5 Comments
Rochelle Ann Flores
Rochelle Ann Flores on 2 Aug 2017
how can I be able to like "increment" the read function. Like
  • int x= 1
  • if x = 1
  • then read next letters % how can I code this part?
  • if x is not 1
  • then steady

Sign in to comment.

Accepted Answer

ES
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);

More Answers (0)

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!