reading specific data from a ascii file
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Titus Edelhofer
am 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 Kommentare
Titus Edelhofer
am 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!