フィルターのクリア

how can I read a text file line by line containing titles of the research papers?

8 ビュー (過去 30 日間)
shabnam
shabnam 2012 年 8 月 7 日
I have a text file that contains titles of the research papers and I have to make dictionary from it so I need to read that file and make dictionary of it. If anyone have some idea then please answer me the question. Thanks

回答 (3 件)

Babak
Babak 2012 年 8 月 7 日
Hi shabnam jan, There is this command in MATLAB where you can read from a text file. It is like this: text = fileread(filename)
Other command that might be useful for text files are as follows:
textread
csvread
textscan
Refer to MATLAB documentation to see the details on these commands :)

John Petersen
John Petersen 2012 年 8 月 7 日
The format of the file is important. The following code assumes each line is a title.
fileid = fopen(filename);
ind = 0;
while(1)
ind = ind+1;
titles{ind} = fgetl(fileid);
if ~ischar(tline), break, end
end
fclose(fileid);
The cellarray 'titles' now contains all the titles. Hope that helps.

Walter Roberson
Walter Roberson 2012 年 8 月 8 日
titles = regexp( fileread(YourFileName), '\n', 'split');

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by