Physics 3: Fitting Procedure Example


Let's suppose that the file 'SiliconDiodeIV.txt' contains the following data:

#Time V1 V2
0.00000e+00 6.00000e-02 6.50000e-02
1.00000e+00 1.25000e-01 1.25000e-01
2.00000e+00 2.00000e-01 2.00000e-01
3.00000e+00 2.75000e-01 2.75000e-01
4.00000e+00 3.60000e-01 3.65000e-01
5.00000e+00 4.30000e-01 4.50000e-01
6.00000e+00 4.75000e-01 5.60000e-01
7.00000e+00 5.00000e-01 6.65000e-01
8.00000e+00 5.20000e-01 8.00000e-01
9.00000e+00 5.35000e-01 9.30000e-01
1.00000e+01 5.50000e-01 1.10000e+00
1.10000e+01 5.60000e-01 1.28000e+00
1.20000e+01 5.75000e-01 1.51000e+00
1.30000e+01 5.85000e-01 1.74000e+00
1.40000e+01 5.95000e-01 2.04000e+00
1.50000e+01 6.05000e-01 2.37500e+00
1.60000e+01 6.10000e-01 2.75000e+00
1.70000e+01 6.20000e-01 3.10500e+00
1.80000e+01 6.25000e-01 3.43500e+00
1.90000e+01 6.25000e-01 3.44500e+00

1- To load the data from file 'SiliconDiodeIV.txt' and select the proper columns type:

[V1,V2] =FitLoad('SiliconDiodeIV.txt',2,3);


2- To compute the uncertainty on the measured voltages type:

sV = 5/2^10/sqrt(12);


4- To create a vector same length of the data points containing the uncertaities on V1 type:

sV1 = V1*0+sV;


5- To define the Resistance R and its uncertainty sR type:

R = 1000; sR=1;


6- To compute the current I flowing through the resistor Rx type:

I = (V2-V1)/R;


7- To compute the uncertaities on the current flowing through the resistor Rx type:

sI = sqrt( (sR*(V2-V1)./R^2).^2 + 2*(sV/R)^2);


8- to Fit the data with an exponential curve type:

FS = FitExp(V1,sV1,I,sI,1e-8,.1,1e-8);


A plot with theoretical curve fitted to the experimental data and the difference plot is shown. The following brief report of the fitting results is printed also
Parameters:
                        a =  3.49192e-06 +-  8.81600e-07
                        b =  2.17489e+01 +-  4.02600e-01
                        c = -5.92864e-03 +-  1.25300e-02

Degrees of Freedom = 17

Reduced ChiSquare = 270.052

Correlation Matrix:
                        a  1.00
                        b -1.00  1.00
                        c -0.63  0.62  1.00
The returning new fields of the FS structure are respectively:
FS.p vector of parameters
FS.sp vector of parameters' uncertainties
FS.CC cross correlation matrix
FS.Xn_p reduced chi square

9. Produce PDF report file with the command:

FitPDFReport(FS,'SiliconDiodeIV');


After a resonable time a file "SiliconDiodeIV.pdf" with the graphical and numerical result of the fit is created.


Home Page