Textscan issues while from file
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I have some issues with textscan function.
fid = fopen('winadcp.txt','r') ;
data = textscan(fid,'%d %d','Delimiter',' ','HeaderLines',16)
D=cell2mat(data);
fclose(fid);
When i run the code(eg), the values stored in D is across the coloumn(attached)
댓글 수: 0
답변 (1개)
DGM
2022년 1월 29일
I have no idea what this data is, but I'm going to guess that reading every other value into two vectors makes no sense. Since I don't know what it is, I'm just going to read it into a single vector. There appear to be seven samples and then a timestamp for an 8th sample, but no corresponding data. I discard the dangling timestamp because I assume it's of no use. The rest I just reshape into a 7x117 matrix, one row per sample. If you know what everything is in each sample, you can further split the rows into their relevant blocks.
fid = fopen('test.txt','r') ;
data = textscan(fid,'%d','Delimiter',' ','HeaderLines',16);
D = cell2mat(data);
fclose(fid);
% define the size of each sample
blocksize = 117;
% truncate and reshape
nblocks = floor(numel(D)/blocksize);
D = reshape(D(1:nblocks*blocksize),blocksize,nblocks).'
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!