-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinearRegression_Example.m
More file actions
30 lines (24 loc) · 1.14 KB
/
Copy pathLinearRegression_Example.m
File metadata and controls
30 lines (24 loc) · 1.14 KB
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
%% Make up data
T = [16.1561125,18.1151125,20.07157222,22.026425,23.9853375,25.9468875,27.9159875,29.894]' + 273.15;
sigma_T = [9.01388E-05,0.000275379,0.000346811,0.000302765,0.000364005,0.000320156,0.001078193,0.000509902]';
R = [14769.5684,13526.27368,12403.6318,11383.356,10447.22,9596.172,8815.85,8105.7267]';
sigma_R = [0.3921,0.1914,0.3913,0.1098,0.2502,0.2973,0.0957,0.1236]';
uR = 100*sigma_R;
uT = 10*sqrt((2*sigma_T).^2 + 0.003.^2);
uOneOverT = uT ./ T.^2;
%% define the model
modelStr = 'A + B*log(x) + D*(log(x))^3'; % make it with ' ' and a function of x
params = ["A","B","D"]; % must use " "
%% Call the LinearRegression function
% WLS
wls = LinearRegression(R, 1./T, uOneOverT, modelStr, params, ...
'transformFcn', @(v) 1./v - 273.15, ...
'xLabel', 'R ($\Omega$)', 'yLabel', 'T (deg C)', ...
'residScale', 1000, 'residUnit', 'mK', ...
'plotTitle', 'Title goes here');
% TLS
tls = LinearRegression(R, 1./T, uR, uOneOverT, modelStr, params, ...
'transformFcn', @(v) 1./v - 273.15, ...
'xLabel', 'R ($\Omega$)', 'yLabel', 'T (deg C)', ...
'residScale', 1000, 'residUnit', 'mK', ...
'plotTitle', 'Title goes here');