5.3 Zeitkonstanten, Least Squares Parameteridentifikation
´´´matlab
scss
% Import necessary libraries
import numpy as np
from matplotlib import pyplot as plt
from scipy.optimize import curve_fit

% Load data from file
data = np.loadtxt('data.csv', delimiter=',')

% Define functions for plotting
def plot_time_series(x, y):
fig, ax = plt.subplots()
  ax.plot(x, y)
  ax.set_xlabel('Time (s)')
  ax.set_ylabel('Temperature (°C)')
  ax.grid(True)
  return fig, ax

% Define functions for fitting the curves
def fit_curve(x, y, t0, T0, Tb):
  A = np.exp(-Tb * x / T0)
  B = np.log(1 + (A / (1 - A)))
  return A * np.exp(B * x / T0)

def fit_saturation(x, y, t0, T0, Tb):
  def saturation(x, t0, T0, Tb):
    return T0 + (Tb - T0) * np.exp(-x / t0)
  return curve_fit(saturation, x, y, p0=[t0, T0, Tb])[0]

% Fit curves to data
fig1, ax1 = plot_time_series(data[:, 0], data[:, 1])
ax1.plot(fit_curve(data[:, 0], data[:, 1], t0=30, T0=25, Tb=10))
fig2, ax2 = plot_time_series(data[:, 0], data[:, 2])
ax2.plot(fit_saturation(data[:, 0], data[:, 2], t0=30, T0=25, Tb=10))

% Calculate difference between time constants
T_diff = np.abs(fit_curve(data[:, 0], data[:, 2], t0=30, T0=25, Tb=10)[0] - fit_saturation(data[:, 0], data[:, 2], t0=30, T0=25, Tb=10)[0])

% Print result
print('The difference between the time constants of the two sensors is:', T_diff)
´´´
5.4 Parameter B des NTC
EASY STUFF!!!