vref = 3.3/2; R4 = 75e3; R3 = 1e6; scope_gain = 4; TOP = 2048; global saved_waveform_ch1; global fastmode tt = 2.5; bt = 0.8; vcc = 3.3; tic top_val = (tt/vref * R4/(R3+R4) * scope_gain * TOP) bot_val = (bt/vref * R4/(R3+R4) * scope_gain * TOP) samples_per_sec = 375000 / (3 * fastmode + 1) range = length(saved_waveform_ch1) - samples_per_sec / 5 gtt = saved_waveform_ch1(range:end)>top_val; gtb = saved_waveform_ch1(range:end)