% Ultrafast Fibre Laser Experiment, University of Toronto.
% Written by: Gajanan Kuganesan Date: Spring 2004.
% Programmed for MATLAB 6.1, (available on Faraday via Nortel Labs).
%
% The following code imports the oscilloscope data for the Autocorrelator
% Trigger, Speaker Signal, and Measured Interferometric Autocorrelation
%
% File: ref1 contains Autocorrelator Trigger (channel 1) and Speaker (channel 2)
% FIle: ref2 contains Inteferometric Autocorrelation Signal.
%
% Imported Data: Data can be imported from LABVIEW software (oscilloscope)
% available on the UFL computer. Data from LABVIEW should be saved as an
% Microsoft Excel file (*.xls), the setup data (first few lines) should be
% recorded and then elminated to be compatiable with the below code.
% That is the data imported should contain only 2 column in an *.xls file;
% the first column contains the oscilloscope voltage data and the second
% column contains the oscilloscope time data.

%*****************************************************************************

clear; %clear previous data
rawdata = importdata('c:\ultra1b\ref1.xls'); %Imports data as formatted above
rawdata2 = importdata('c:\ultra1b\ref2.xls'); %Imports data as formatted above

ch1div = 0.5; %channel 1 volts/division, in milliVolts
ch1pos = 0.5; %channel 1 position w.r.t. rawdata zero
ch2div = 2; %channel 2 volts/division, in milliVolts
ch2pos = -4; %channel 2 position w.r.t. rawdata zero
ch3div = 50; %channel 3 volts/division, in milliVolts
ch3pos = -20; %channel 3 position w.r.t. rawdata zero

% Arrange raw data into Voltage vectors
for i = 1:length(rawdata)
voltage1(i) = rawdata(i,1);
voltage2(i) = rawdata(i,2);
voltage3(i) = rawdata2(i,1);
time(i) = rawdata(i,3);
end;

% Set up Vectors pased on Settings
voltage1 = voltage1*ch1div - ch1pos;
voltage2 = voltage2*ch2div - ch2pos;
voltage3 = voltage3*ch3div - ch3pos;

%*****************************************************************************

% The following plots display the Trigger, Speaker and Autocorrelation Signals
subplot(3,1,1); plot(time,voltage2);
title('Function Generator Sync Signal: Oscilliscope'); ylabel('Voltage (V)');
subplot(3,1,2); plot(time,voltage1);
title('Sinusoidal Speaker Signal: Oscilliscope');
ylabel('Voltage (V)');
subplot(3,1,3); plot(time,voltage3);
title('Interferometric Autocorrelation Signal: Oscilliscope');
ylabel('Voltage (mV)'); xlabel('Time [s]');

%text(-10,60, num2str(max(voltage1)));