フィルターのクリア

reading text file to matlab

1 回表示 (過去 30 日間)
muthu kumar
muthu kumar 2012 年 7 月 28 日
hello frds i want to read a text file which contains many image names . i want to read each name and to do some process on that image , ur help needed my problem is how to store the data that i read from textfile in matlab and on each name(image) i have to do some process.
fid = fopen('dbname.txt','r');
t=[];
tline = fgets(fid);
while ischar(tline)
disp(tline)
s=tline;
t= [t,s];
tline = fgets(fid);
end
fclose(fid);
celldata=cellstr(t);
but i couldnot access individual file name ur suggestions are helpful to me thanks

採用された回答

Wayne King
Wayne King 2012 年 7 月 28 日
Are the file names such that there is 1 per line in the text file? If so, the following works for me. I've just changed your
t = [t,s]
to
t = [t;s]
fid = fopen('dbname.txt','r');
t=[];
tline = fgets(fid);
while ischar(tline)
disp(tline)
s=tline;
t= [t;s];
tline = fgets(fid);
end
fclose(fid);
celldata=cellstr(t);
Now you can access the individual file names with regular cell array indexing
celldata{1}
celldata{2}
  1 件のコメント
muthu kumar
muthu kumar 2012 年 7 月 30 日
thank u

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by