フィルターのクリア

problems with reading a text file in matlab

2 ビュー (過去 30 日間)
Farjana Yeasmin
Farjana Yeasmin 2014 年 11 月 24 日
コメント済み: Farjana Yeasmin 2014 年 11 月 25 日
my file is :
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccccccccccccccccc
ddddddddddddddddddddddddddddddddd
eeeeeeeeeeeeeeeeeeeeeeeee
ffffffffffffffffff
my code is :
fid = fopen('RealInfo.txt','r'); % Open text file
InputText = textscan(fid,'%s',4,'delimiter','\n'); % Read strings delimited
% by a carriage return
Intro = InputText{1};
disp(Intro);
when i try to read the file , then it shows only 3 line in the command window ,how can i solve the problem .?
there is another problem with the code , when my file like : aaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccc
it can not readthe file.. so , how can i fix the two problem ? it does not

採用された回答

Orion
Orion 2014 年 11 月 24 日
You asked to read only the 4 first line
InputText = textscan(fid,'%s',4,'delimiter','\n');
change it to
InputText = textscan(fid,'%s','delimiter','\n');
Now, you have all your textfile.
  3 件のコメント
Orion
Orion 2014 年 11 月 24 日
編集済み: Orion 2014 年 11 月 24 日
I attached a text file and a code to read it.
this works for reading and displaying.
adapt it to your full code and text
Farjana Yeasmin
Farjana Yeasmin 2014 年 11 月 25 日
thank you

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by