reading specific data from a ascii file
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
Titus Edelhofer
2013년 6월 24일
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
Titus Edelhofer
2013년 6월 25일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!