Reading particular column numbers in Matlab

3 ビュー (過去 30 日間)
subharthi chowdhuri
subharthi chowdhuri 2016 年 7 月 14 日
回答済み: Shameer Parmar 2016 年 7 月 14 日
I have a large text file where the number of rows are 51,83,005 and the number of columns are 39. I want to read some specific columns from this file, like for example columns 4:7 , columns 9:12 , columns 14:17 like this. How can I do that using textscan?

回答 (2 件)

Shameer Parmar
Shameer Parmar 2016 年 7 月 14 日
You can do this..
Data = textread('abc.txt', '%s', 'delimiter', '');
Make sure that the abc.txt file is present in current directory.
It will create variable 'Data' which store all data from your text file..
Now Do this :
Column1 = {};
Column2 = {};
Column3 = {};
for count = 1: size(Data,1)
RowData = Data{count};
Column1{count,1} = RowData(4:7);
Column2{count,1} = RowData(9:12);
Column3{count,1} = RowData(14:17);
end
at the end, you will get three columns with required data and the rowsize will be the same.
So now if you want to read specific data, for example, all three column data but at row 5, then you can apply such logic.
RequiredData1 = Column1{5};
RequiredData2 = Column2{5};
RequiredData3 = Column3{5};
Let me know if you face any issue..

Fatih Olmez
Fatih Olmez 2016 年 7 月 14 日
編集済み: Fatih Olmez 2016 年 7 月 14 日

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by