%Program used to find the half time from the flash diffusivity technique
%Written by Trent Ward
%last revised April 27, 2005
clear all;
close all;
data=load('23run7.txt'); %load specific data file from experiment
datax=data(:,3); %define time scale from data
datay=data(:,2); %define voltage scale from data
size=size(datax); %find the size of data file (number of points)
smoothed = smooth(datax,datay,.15,'lowess'); %perform smoothing on data using the "Lowess" smoothing weight function for a span of 15% of the data points
if max(datay)<0 %condition to see if the voltage is negative, reversed polarity
for i=1:size %search over the data set
tol=(smoothed(i+1)-smoothed(i)); %set the tolerance to find the temperature interval where the half time is
if smoothed(i)<=(min(smoothed)+max(smoothed))/2-tol %if the data is in the region of the half time, then this is the half time
disp(i+1);disp(datax(i+1)); %display the half time
break %stop the loop, no need to continue
end
end
else %for the positive voltage
for i=1:size %search over the data set
tol=(smoothed(i+1)-smoothed(i)); %set the tolerance to find the temperature interval where the half time is
if smoothed(i)>=(min(smoothed)+max(smoothed))/2-tol %if the data is in the region of the half time, then this is the half time
disp(i+1);disp([datax(i+1)]); %display the half time
break %stop the loop, no need to continue
end
end
end
plot(datax,smoothed) %plot the data fro the smoothed curve
hold on
plot([datax(i+1),datax(i+1)],[min(smoothed),max(smoothed)],'r-') %display the half time using a vertical line