How do you replicate textread functionality with textscan?

I have been working with some code that reads in a text file using textread. The textread approach is simple and works perfectly for what I want. It reads in the text file and allows me to access each line by using a number - so line 176 is file(176).
This is what I used for textread:
inFile = textread('filename','%s','delimiter','\n');
The problem is that apparently textread is going to be removed in future versions and Matlab says to use textscan instead. However, I can't figure out how to replicate this functionality with textscan.
Using textscan, instead of data set that is indexable line by line, I get an entire data file in a single 1x1 cell.
This is the kind of thing I have been trying with textscan:
inFile = textscan(fid, '%s','EndOfLine','\n','Delimiter','\n')
I would greatly appreciate any help in getting the previous functionality.

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 1 月 11 日

0 投票

If your cell array is data, then you can get each line you want
x=data{:}
line20=x(20,:)

1 件のコメント

Brian
Brian 2013 年 1 月 11 日
That fixes it perfectly. Thank you for your help! :)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Import and Export についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by