This Matlab function I created, basically takes a csv file generated by tektronix osciloscopes and plots the signals for two channels. However, every test and csv file created has a different number of points (for this case is 9999
, meaning [B16:B10014]
) and a different name for the worksheet in excell(tek0001ALL
). I'm new with matlab and this might not be the best code efficient way to do it, so I was wondering if there could be an easier way of having a general code that could plot any csv generated that can detect the last cell filled in those colums and the number of cells so it can also be the number of points since sometimes it is required to perform a lot of tests.
function [ Vs1, Vs2, t ] = scope![enter image description here][1]( filename )
% Read the Y axis data of the scope data in volts CH1
Vs1 = xlsread(filename, 'tek0001ALL', 'B16:B10014');
% Read the Y axis data of the scope data in volts CH2
Vs2 = xlsread(filename, 'tek0001ALL', 'C16:C10014');
% Read the sample interval from the scope data in seconds
sample_interval = xlsread(filename, 'tek0001ALL', 'B7');
% Create time axis
t = 0:sample_interval:(9999*sample_interval)-sample_interval;
%Plot waveform
figure
subplot(2,1,1);
plot(t,Vs1);
title('Sensor Input Measurements for 100pc Discharge ');
xlabel('Time[s]');
ylabel('Voltage[V]');
grid on;
grid minor;
subplot(2,1,2);
plot(t,Vs2);
title('Sensor Output Measurements for 100pc Discharge');
xlabel('Time[s]');
ylabel('Voltage[V]');
grid on;
grid minor;
end
An example of the CSV file format is the following:
Model,DPO3034
Firmware Version,1.08
Point Format,Y,
Horizontal Units,S,
Horizontal Scale,8e-07,
Sample Interval,8e-10,
Record Length,10000,
Gating,0.0% to 99.9900%,0.0% to 99.9900%
Probe Attenuation,1,1
Vertical Units,V,V
Vertical Offset,0,0
Vertical Scale,0.05,0.001
Label,,
TIME,CH1,CH2
-1.4664e-06,-0.003,-0.00036
-1.4656e-06,-0.003,-0.00036
-1.4648e-06,-0.003,-0.00036
-1.4640e-06,-0.001,-0.00032
-1.4632e-06,-0.003,-0.00036
-1.4624e-06,-0.001,-0.00036
-1.4616e-06,-0.001,-0.0004
-1.4608e-06,-0.003,-0.00036