%Constant
ns=10^(-9);
us=10^(-6);
ms=10^(-3);

%Connection
interfaceObj = visa('tek', 'USB::0x0699::0x03B3::C010453::INSTR');%your instrument
deviceObj = icdevice('tektronix_tds2014', interfaceObj);
connect(deviceObj);

%Measurement period
T=10.0*us;
t=(1:2500)/T;

%Trigger setting
deviceObj.trigger.source='external';
deviceObj.trigger.coupling='dc';
deviceObj.trigger.triggertype='edge';
deviceObj.trigger.mode='normal';
deviceObj.trigger.slope='rising';
deviceObj.trigger.level=1.0;
deviceObj.acquisition.delay=T/2;
deviceObj.acquisition.timebase=T/10;

%Channel setting
for i=1:4
    deviceObj.channel(i).coupling='dc';
    deviceObj.channel(i).bandwidthlimit='off';
    deviceObj.channel(i).state='on';
end


for j=1:10
    
    deviceObj.acquisition.control='single';
    deviceObj.acquisition.state='run';
    
    while(strcmp(deviceObj.acquisition.state,'run'))
        
    end
    
    disp('Now reading...');
    V1 = invoke(deviceObj.Waveform, 'readwaveform', 'channel1');
    V2 = invoke(deviceObj.Waveform, 'readwaveform', 'channel2');
    V3 = invoke(deviceObj.Waveform, 'readwaveform', 'channel3');
    V4 = invoke(deviceObj.Waveform, 'readwaveform', 'channel4');
    disp('Finish!');
    
    subplot(2,2,1)
    plot(t,V1)
    subplot(2,2,2)
    plot(t,V2)
    subplot(2,2,3)
    plot(t,V3)
    subplot(2,2,4)
    plot(t,V4)
    drawnow;
    
end

%Disconnection
disconnect(deviceObj);
clear deviceObj;