该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
自个儿搞清楚了……不算很难,就是略繁。重点是参照
forums.ni.com/attachments/ni/60/4652/2/LeCroyWaveformTemplate_2_3.pdf
中的格式说明。以下给出代码(其实可以进一步整理成函数的,我懒得弄了……):
str = OpenRead[(*文件地址*), BinaryFormat -> True];
byte = "Integer8";
word = "Integer16";
long = "Integer32";
string = "TerminatedString";
float = "Real32";
double = "Real64";
SetStreamPosition[str, 0];
lengthofwavedesc = 8;
headlength = StringLength@BinaryRead[str, string] - lengthofwavedesc;
l@wavedesc = read[36, long];
l@usertext = read[40, long];
l@trigtimearray = read[48, long];
l@ristimearray = read[52, long];
l@wavearray = read[116, long];
read[pos_, type_] := (SetStreamPosition[str, headlength + pos]; BinaryRead[str, type])
readlist[pos_, type_, length_] := (SetStreamPosition[str, headlength + pos];
BinaryReadList[str, type, length])
raw = readlist[l@wavedesc + l@usertext + l@trigtimearray + l@ristimearray, byte,
l@dataarray@1];
{vertical@gain, vertical@offset} = readlist[156, float, 2];
data = vertical@gain * raw - vertical@offset;
horizon@interval = read[176, float];
horizon@offset = read[180, double];
rightboundary = horizon@interval (l@wavearray - 1) + horizon@offset;
Close@str;
ListLinePlot[data[[;; ;; 10]], DataRange -> {horizon@offset, rightboundary}]
顺便,那个MATLAB的.m文件其实是bug,它在算文件位置的时候丢了一项。(当然这项一般是空的所以通常不会引发问题。)