从示波器中捕获的波形处理,此代码源于https://ww2.mathworks.cn/matlabcentral/fileexchange/14918-tektronix-wfm-file-reader
function:
1 function [out_descript, outdata, timedata] = wfm_ascii_dpo(fname, data_start, data_stop)
2 % Converts TSD5/6/7k and DPO7k/70k .wfm file to ASCII format
3 % with time array
4 %
5 % data_start and data_stop input arguments are optional
6 % and can be used to read parts of file
7 %
8 % To do: implement fast frame, pixel maps
9 %
10 out = [];
11 if nargin==0
12 fname='';
13 end
14 if isempty(fname)
15 [filename,pname]=uigetfile({'*.wfm', 'Tektronix Waveform Files (*.wfm)';'*.*', 'All Files (*.*)'},'Choose Tektronix WFM file');
16 fname=[pname filename];
17 end
18 %---Open file
19 fd = fopen(fname,'r');
20 if fd==-1
21 error('Problem opening file "%s"',fname)
22 end
23 %---Determine byte ordering, then close and reopen with proper byte ordering
24 ByteOrder = fread(fd,1,'ushort');
25 if ByteOrder==61680
26 fclose(fd);
27 fd = fopen(fname,'r','ieee-be');
28 else
29 fclose(fd);
30 fd = fopen(fname,'r','ieee-le');
31 end
32 %---WFM static file information
33 out.ByteOrder = fread(fd, 1,'ushort' );
34 out.Ve