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 で Standard File Formats についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!