reading specific data from a ascii file

3 visualizaciones (últimos 30 días)
Vinay Kumar
Vinay Kumar el 24 de Jun. de 2013
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.

Respuesta aceptada

Titus Edelhofer
Titus Edelhofer el 24 de Jun. de 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 comentarios
Vinay Kumar
Vinay Kumar el 24 de Jun. de 2013
Hi Titus, %*f is not working. I mean, it doesn't skips the lines. Could you please shed some more light to your solution. Thanks.
Titus Edelhofer
Titus Edelhofer el 25 de Jun. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by