Read Particular Line Number from String-Num Text File

3 ビュー (過去 30 日間)
Rehan Rehan
Rehan Rehan 2016 年 11 月 15 日
コメント済み: Jan 2016 年 11 月 15 日
Hi,
I have the following text file saved as .dat or .txt file...
103 (ABCDEF GEF HIJ KLMN)
BS 25
gravity_axis = y
As you can see there are numbers as well as strings. I want Matlab to read from a particular line number when needed. e.g.
At line-1 and Col-1 : 103
At line-2 and Col-1 : BS
At line-2 and Col-2 : 25
At line-3 and Col-1 : gravity_axis
At line-3 and Col-3 : y
So, I want it these be read through their respective addresses in a simple code.
Best regards, REHAN
  1 件のコメント
Jan
Jan 2016 年 11 月 15 日
The question is not clear. What is the desired output?

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

回答 (1 件)

KSSV
KSSV 2016 年 11 月 15 日
fid = fopen('yourfile') ;
S = textscan(fid,'%s','delimiter','\n') ;
fclose(fid) ;
S=S{1} ;
You can access your lines using S{1}, S{2} etc.
  1 件のコメント
Rehan Rehan
Rehan Rehan 2016 年 11 月 15 日
Thanks a lot.
But still I cannot get column-wise entries. I mean to say that with your code, I am getting rows (lines). But from within lines I am unable to get text (Number or string) at particular position within the selected line.

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

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by