-
Notifications
You must be signed in to change notification settings - Fork 0
/
four_probe.m
71 lines (55 loc) · 2.41 KB
/
four_probe.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
%% Import data from spreadsheet
% Script for importing data from the following spreadsheet:
%
% Workbook: C:\Users\abc\Documents\MATLAB\4 probe_heating curve.xlsx
% Worksheet: Sheet1
%
% Auto-generated by MATLAB on 30-Apr-2022 13:22:56
%% Setup the Import Options and import the data
opts = spreadsheetImportOptions("NumVariables", 2);
% Specify sheet and range
opts.Sheet = "Sheet1";
opts.DataRange = "A1:B16";
% Specify column names and types
opts.VariableNames = ["VarName1", "VarName2"];
opts.VariableTypes = ["double", "double"];
% Import the data
probeheatingcurve = readtable("C:\Users\abc\Documents\MATLAB\4 probe_heating curve.xlsx", opts, "UseExcel", false);
%% Clear temporary variables
clear opts
% Parameters
k = 2.303; % conversion factor
kB = 8.617*1e-5; % value of Boltzmann's constant
four_probe_data = table2array(probeheatingcurve); % imported data in the form of homogeneous arrays
temp_data = four_probe_data(:, 1); % temperature data
volt_data = four_probe_data(:, 2); % voltage data
resistivity_data = volt_data./2.93; % resistivity data
% Visualization
figure(1);
plot(temp_data, resistivity_data, 'k', 'LineWidth', 2);
grid
xlabel('Temperature [K]', 'interpreter', 'none', 'FontSize', 20);
ylabel('$\rho$ [ohm. cm.]', 'interpreter', 'latex', 'FontSize', 20);
% Log values of resistivity (base 10)
resistivity_data_new = log10(resistivity_data); % log base 10 values of resistance
inverse_temp = (temp_data.^-1); % inverse temperature data
% Linear fitting of the data
beta0 = [1.34; -0.0024].*1e3; % initial guesses for the parametric fit
% Fitting to a linear model
f = @(b, inverse_temp) b(1).*inverse_temp + b(2);
% Parametric fitting using fminsearch
para_vals = fminsearch(@(b) norm(resistivity_data_new - f(b, inverse_temp)), beta0); % Estimating fitting parameters
% Visuaalization of the linear fit
yfit = f(para_vals, inverse_temp);
figure(2); % for the linear fit
plot(inverse_temp, resistivity_data_new, 'ko');
hold on
plot(inverse_temp, yfit, 'r', 'LineWidth', 2);
grid
xlabel('$1/T [K^{-1}]$', 'interpreter', 'latex', 'FontSize', 20);
ylabel('$log_{10} (\rho)$', 'interpreter', 'latex', 'FontSize', 20);
legend('Experimental data', 'Linear fit', 'FontSize', 19, 'Orientation', 'vertical', 'Location', 'best');
% Bandgap estimation
para_vals(1) = para_vals(1)/1e3;
para_vals(1) = para_vals(1)/1e-3;
Eg = para_vals(1)*2*k*kB; % value in eV