clear all; close all; clc;

% messdaten
x=1e-3*[0.56;0.47;0.41;0.35;0.30;0.26;0.23;0.19;0.16;0.12;0.09;0.06;0.04;0.01];                                 % ~ height_m
y=1e3*[0.9995;0.9996;0.9998;1.0000;1.0002;1.0003;1.0005;1.0007;1.0008;1.0010;1.0012;1.0013;1.0015;1.0017];      % ~ rho_verlauf_exp_kg_m3

figure(1); plot(x,y,'.'); hold on;

% Glättungsfaktor!
% lambda=1;                         % jeder messpunkt wird exakt getroffen
lambda=0.9999999999999;           % leichte glättung der messdaten
% lambda=0.99999999;                  % starke glättung, lösung geht gegen eine regressionsgerade

% Cubic Smoothing Spline
pp=csaps(x,y,lambda);               % erzeugt cubic smoothing spline
xpp=linspace(x(1),x(end),1000);     % höhere auflösung
ypp=fnval(pp,xpp);                  % wertet den spline bei xpp aus

figure(1); plot(xpp,ypp,'r');



