reading specific data from a ascii file
5 views (last 30 days)
Show older comments
HI everyone,
I am trying to access and import a part of a very large file (.ascii format) in matlab workspace. I tried with two approaches: 1. 'dlmread' but the exported data converts the -ve values into zero. I tried with changing the format with 'format long e' but no success. 2. fid = fopen('C:\s4.ascii'); format = repmat('%f', [1 nCols]); c = textscan(fid, format); here the problem is 'How to get a particular range of columns and rows in to matlab?'
Any help.
Thanks in advance.
0 Comments
Accepted Answer
Titus Edelhofer
on 24 Jun 2013
Hi,
for the columns you can use %*f to skip a column. Building the format string will be slightly more complicated of course, depending on which columns you want to have...
Second, for the rows, take a look at the third parameter 'N' for reading a specified number of rows and look for 'headerlines' to skip a specified number of rows ...
Titus
2 Comments
Titus Edelhofer
on 25 Jun 2013
Hi Vinay,
the %*f skips a column, not a line. For reading only a particular set of lines you would call textscan several times with using the "headerlines" parameter to skip a number of lines.
Titus
More Answers (0)
See Also
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!