.. highlightlang:: us .. index:: nonlin .. _nonlin: nonlin ====== .. us.tag nonlin GERMAN interpol-2d Interpolation :ref:`nonlin` berechnet die Parameter einer gegebenen (nichtlinearen) Funktion, so daß die Abweichung der Funktion zu gegebenen Datenpunkten minimiert wird. .. function:: pEnd = nonlin(fit, y, x, pStart) pEnd = nonlin(fit, y, x, pStart, bPrint) .. us.return **Returnwert** *pEnd* sind die Parameter der Funktion *fit*. .. us.params **Parameter** .. uparam:: fit *fit* ist eine vom Benutzer bereitzustellende Funktion (siehe Beispiel). .. uparam:: y *y* ist ein Spaltenvektor mit den y-Koordinaten der Daten. .. uparam:: x *x* ist ein Spaltenvektor mit den x-Koordinaten der Daten. .. uparam:: pStart *pStart* ist ein geschätzter Startvektor. .. uparam:: bPrint Wenn *bPrint* FALSE (0) ist, werden keine Informationen im Kommandofenster ausgegeben. .. us.example **Beispiel** :: def fit_exp(x, p) { return p[1] + p[2] .* exp(p[3] .* x); } rmXY = [ .. 1.2600, 0.4000; 1.6000, 0.2800; 1.6300, 0.2900; 1.6500, 0.2300; 1.6900, 0.2000; 1.7000, 0.1850; 1.7600, 0.1600; 2.0000, 0.0750; 2.2300, 0.0550; 2.5000, 0.0400]; p_start = [0,0,0]; p_end = nonlin(fit_exp, rmXY[;2], rmXY[;1], p_start); x = linspace(1.2, 2.6, 50); y = fit_exp(x', p_end); h = plot(x, y); h = plot (rmXY[;1], rmXY[;2], h[2]); XYShowMarker(h[3], TRUE); XYShowLine(h[3], FALSE); PageReplot(h[1]); :ref:`nonlin` kann auch für xyz-Datensätze verwendet werden, hier ein Beispiel: :: def fit_xyz_poly2(_x, p) { x = _x[;1] y = _x[;2] return p[1] + .. p[2] .* x + .. p[3] .* y + .. p[4] .* x .* x + .. p[5] .* y .* y + .. p[6] .* x .* y; } def test2(hDataXYZ) { rmXYZ = XYZGetData(hDataXYZ); p_start = zeros(1,6); [0.1, 1, 1, 1, 0.01, 1]; p_end = nonlin(fit_xyz_poly2, rmXYZ[;3], rmXYZ[;1,2], p_start); Z = fit_xyz_poly2(rmXYZ[;1,2], p_end) plotmatrix(rmXYZ[;1], rmXYZ[;2], Z) } .. image:: S:/uniplot-obj/images/fit.* .. seealso:: :ref:`uberblick-mathematik`, :ref:`fspline`, :ref:`pspline`, :ref:`plot` :sub:`id-697354`