My code can not read a text from text file.

Hi guys
I am asking the matlab to display a text inside a word file and I am using this code but matlab shows the word like this: |]<„g®¾Q;a0طî$¶UڑMکًأKٹS°؛
What is the problem?
fileID = fopen (filename,"rt");
if fileID < 0
error('error opning file %s/n/n',filename)
end
tline = fgets(fileID);
while ischar (tline)
fprintf('%s %c',tline)
tline = fgets(fileID);
end
fprintf('/n');
fclose(fileID);

댓글 수: 5

Stephen23
Stephen23 2019년 6월 1일
편집: Stephen23 2019년 6월 1일
@Abdullah Alsuhaymi: please upload a sample data file by clicking the paperclip button.
thank you for your help so much
Stephen23
Stephen23 2019년 6월 1일
편집: Stephen23 2019년 6월 1일
@Abdullah Alsuhaymi: your code imports data from a data file. Please upload a sample data file.
"I am asking the matlab to display a text inside a word file "
What exactly do you mean by a "word file" : are you working with text files (which are not "word files" by any common definition of the term) or are you use Microsoft Office proprietary format such as Open Office XML .docx ? Using correct terminology makes it easier for people to understand what you are asking about and what you are trying to do.
yeah ,the file I am using is .docx
I am trying to make matlab display all the text inside a text file which format is .docx
I couldnot upload the file because the format .docx is not supported here.
thank you
dpb
dpb 2019년 6월 1일
ML doesn't have builtin Word file reader -- either save the file as plain text from Word or you'll have to use COM to drive Word and that then becomes a Word forum question as to what is the syntax for it, not Matlab at all.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import and Export에 대해 자세히 알아보기

태그

질문:

2019년 6월 1일

댓글:

dpb
2019년 6월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by