Read from txt file
조회 수: 33 (최근 30일)
이전 댓글 표시
I have to 1) Read in a dictionary of common English words from words.txt.
and
2) Read in an email with misspellings from email.txt
in one file
I just started learning matlab and I am a beginner. I did this, but it doesn't work. Help please.
==
==
fip = fopen('words.txt', 'r');
Data = fread(fid);
CharData = char(Data);
fclose(fid);
disp(Data);
fip = fopen('email.txt', 'r');
Data = fread(fid);
CharData = char(Data);
fclose(fid);
disp(Data);
댓글 수: 0
채택된 답변
Lalit Patil
2013년 2월 23일
% Try this
fid = fopen('words.txt', 'r');
Data = fread(fid);
CharData = char(Data);
fclose(fid);
disp(Data);
fid = fopen('email.txt', 'r');
Data = fread(fid);
CharData = char(Data);
fclose(fid);
disp(Data);
If not works than what is the error..? Show it..
댓글 수: 2
Lalit Patil
2013년 2월 23일
CStr = textread('words.txt', '%s', 'delimiter', '\n')
Try this only single line..
추가 답변 (1개)
Image Analyst
2013년 2월 23일
What doesn't work? You read in two files, and that's what you were supposed to do. So what doesn't work? Please copy and paste your error message or whatever else tells you that it is not working.
댓글 수: 4
Image Analyst
2013년 2월 23일
You've accepted an answer, so I guess it's solved now, and I don't need to answer.
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!