How to control reading text character by character

8 次查看(过去 30 天)
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 个评论
Rochelle Ann Flores
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

请先登录,再进行评论。

采纳的回答

ES
ES 2017-8-2
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 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by