Reading certain parts of text file

1 次查看(过去 30 天)
ALEX
ALEX 2014-1-13
Hi,
I'm trying to access certain parts of a text to process data. The text file has a header and many rows of numbers, starting at lines 13 through 4016 is a two column array. This is comma delimited. It would be nice to track information of this file located in the header but firstly I just want to bring all of these numbers into Matlab for processing. The formats don't change per text file just the numbers.
Thanks for your help, Alex

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2014-1-13
编辑:Azzi Abdelmalek 2014-1-13
a=importdata('file.txt')
data=a.data
  5 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2014-1-13
编辑:Azzi Abdelmalek 2014-1-13
fid=fopen('file.txt')
out=textscan(fid,'%f %f','HeaderLines',12,'Delimiter',',')
fclose(fid)
M=cell2mat(out)
ALEX
ALEX 2014-1-13
编辑:Azzi Abdelmalek 2014-1-13
I figured it out, there is a special function that does all of this hands free.
num = csvread(filename,13,0)
this data is already comma delimited, so I could open it as a txt file without any problems. If there aren't commas it might not be so easy.
this youtube video was helpful.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Standard File Formats 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by