%**************************************************************************
% DLTS_TRANSIENT_PREPARATION
% Author: Antonio Braga, Zurich Instruments
% May 19, 2015
%
% This script takes one single recorded waveform with multiple transients
% and average them to obtain a single averaged transient. The series of
% transient is saved using DLTS_TRANSIENT_SAVE function. Each series
% represents the measurement at one temperature. It is possible to take
% several transient waveforms recorded at the same temperature and
% average them. (See below example)
%
% Transients_***K: the sampleY variable from the DLTS_TRANSIENT_SAVE
% function. Transient waveforms at different temperature meassurement must
% be assigned to different names.
%
% SR: Transient waveform sample rate. SR should be the same as the Fs
% variable used in DLTS_TRANSIENT_SAVE function
%**************************************************************************
% Give the sample Rate used to acquire your transient waveform
SR = 57600;
% Average Transients_***K_A, Transients_***K_B, Transients_***K_C, etc.
% from the same temperature measurement
% You may want to record transients at the same temperature in different
% variables for more data points.
% example with two set of transients at 240K
% catenate two transients
Set_of_transients = horzcat(Transients_240K_A, Transients_240K_B);
% Count the number of pulses in the Set_of_transients
dummy_Set_of_transients = Set_of_transients;
% vth will define the value where each transient starts in order to overalap all
% transients for averaging later
vth = 0.0024; % an arbitrary value based on obtained transients in this example
% all points below vth are discarded
dummy_Set_of_transients(1:length(Set_of_transients))=sign(Set_of_transients(1:length(Set_of_transients))-vth);
% number of peaks will indicate the number of transients obtained
[~,find_number_of_pulses] = findpeaks(diff(dummy_Set_of_transients));
Number_of_pulses=find_number_of_pulses;
for i=2:length(find_number_of_pulses)
if find_number_of_pulses(i)-find_number_of_pulses(i-1)>(SR/2);
Number_of_pulses(i)=find_number_of_pulses(i);
else Number_of_pulses(i)=0;
end
end
Number_of_pulses(Number_of_pulses==0) = [];
% Returns all the transients measured
for ii = 1:length(Number_of_pulses)-1
zint_i=Number_of_pulses(ii);
zint_f=SR+Number_of_pulses(ii);
eval(['Trns' num2str(ii) '= Set_of_transients(zint_i:zint_f);']);
end
% Transient averaging & plotting
color = summer(length(Number_of_pulses)-1);
sum =0;
for z = 1:length(Number_of_pulses)-1
eval(['y = Trns' num2str(z) ';']);
[valmin,posmin]=min(y);
int_i = posmin;
int_f = posmin + 40000; %this number is arbitrary
eval(['Trns' num2str(z) '= Trns' num2str(z) '(int_i:int_f);']);
str = eval(['Trns' num2str(z) ';']);
plot(str,'Color',color(z,:))
hold on
sum = sum + str;
end
xlabel('Time (s)','fontsize',20);
ylabel('Capacitance (F)','fontsize',20)
title('Average transient','fontsize',28);
% Overlap the averaged tranisent
avg = sum / (length(Number_of_pulses)-1);
plot(avg,'r');
hold on;