2.1. Bearbeiten von Daten

© PD Dr. Jürgen Schnack, Numerische Physik, WS 2003/04

Pakete laden

<<  Statistics`NonlinearFit`;

<< Graphics`Colors`

<< Graphics`Legend`

Einlesen von Daten

data = ReadList["cr8-T-Chi.dat", {Number, Number}]

Darstellen der Daten

\(\(LP1 = 
        ListPlot[data, 
          PlotStyle -> {Hue[0], 
              PointSize[
                0.015]}, 
TextStyle -> {FontFamily -> Helvetica, 
              FontSize -> 
                18}, 
PlotLabel -> "χ", 
          AxesLabel -> {"T (K)", "χ"}];\)\)

Daten (Suszeptibilität) konvertieren zu T χ/gmub

gmub  =  1.985*0.6717;
datb = 
        Table[{data[[i, 1]], 
            data[[i, 1]]*data[[i, 2]]/gmub}, 
{i, 
            1, Length[data]}];

\(\(LP2 = 
        ListPlot[datb, 
          PlotStyle -> {Hue[0], 
              PointSize[
                0.015]}, 
TextStyle -> {FontFamily -> Helvetica, 
              FontSize -> 
                18}, 
PlotLabel -> "Tχ", 
          AxesLabel -> {"T (K)", "Tχ"}];\)\)

Daten durch Linearkombination von vorgegebenen Funktionen approximieren

Fit fittet eine Linearkombination von vorgegebenen Funktionen

f0[x_] = Fit[datb, {1}, x]

f1[x_] = Fit[datb, {1, (1/x)}, x]

f2[x_] = Fit[datb, {1, (1/x), (1/(x^2))}, x]

f7[x_] = 
      Fit[datb, {1, (1/x), (1/(x^2)), (1/(x^3)), (1/(x^4)), (1/(x^5)), (1/(x^6)), 
          (1/(x^7))}, x]

\(\(FP = 
        Plot[{f0[T], f1[T], f2[T], f7[T]}, {T, 0.1, 300}, 
          PlotRange -> {0, 
              11}, 
PlotStyle -> {Green, Blue, Cyan, 
              Black}, 
TextStyle -> {FontFamily -> Helvetica, 
              FontSize -> 
                18}, 
PlotLabel -> "Tχ", 
          AxesLabel -> {"T (K)", "Tχ"}];\)\)

Show[FP, LP2];

determine coefficients with nonlinear fit

7. Ordnung

NonlinearFit fittet eine beliebige von Parametern abhängige vorgegebene Funktionen

TChi7[T_, a_, b_, c_, d_, e_, f_, g_, h_] = 
        a + (b/(T^1)) + (c/(T^2)) + (d/(T^3)) + (e/(T^4)) + (f/(T^5)) + (g/(T^6)) + 
          (h/(T^7));

\(\(\(Para7[T_] = 
      NonlinearFit[datb, 
        TChi7[T, a, b, c, d, e, f, g, 
          h], 
{T}, \ {{a, 20}, {b, 5}, {c, 0}, {d, 0}, {e, 0}, {f, 0}, {g, 
            0}, {h, 0}}]\)\(
\)\(		\)\)\)

\(BestFitParameters\  /. \ 
      NonlinearRegress[
		datb, 
        TChi7[T, a, b, c, d, e, f, g, 
          h], 
\ \ \ \ {T}, \ {{a, 20}, {b, 5}, {c, 0}, {d, 0}, {e, 0}, {f, 
            0}, {g, 0}, {h, 0}}, 
RegressionReport\  -> \ BestFitParameters, 
        MaxIterations -> 50]\)

\(\(P7 = 
        Plot[{Para7[T]}, {T, 0.1, TMax}, 
          PlotRange -> {0, 11}, 
PlotStyle -> {Green, 
              Blue, Cyan, 
              Black}, 
TextStyle -> {FontFamily -> Helvetica, 
              FontSize -> 
                18}, 
PlotLabel -> "Tχ", 
          AxesLabel -> {"T (K)", "Tχ"}];\)\)

Show[P7, LP2];