Skip to content
Snippets Groups Projects
Commit 77d2f519 authored by Lukas Müller's avatar Lukas Müller
Browse files

cleared output and added some comments

parent ed0f3a5b
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Übung 1 # Übung 1
Im Vergleich zu Matlab müssen Pakete in Python importiert werden. Wir importieren daher hier zunächst die Bibliotheken NumPy Im Vergleich zu Matlab müssen Pakete in Python importiert werden. Wir importieren daher hier zunächst die Bibliotheken NumPy
und Matplotlib. und Matplotlib.
NumPy bietet viele mathematische Operationen wie Sinus und Cosinus, aber vor allem auch Matrixoperationen. Matplotlib ermöglicht NumPy bietet viele mathematische Operationen wie Sinus und Cosinus, aber vor allem auch Matrixoperationen. Matplotlib ermöglicht
es uns unsere Berechungen zu visualisieren. es uns unsere Berechungen zu visualisieren.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import numpy import numpy
from matplotlib import pyplot from matplotlib import pyplot
# Ein Notebook spezifischer Befehl zur Darstellung der Grafiken im Notebook # Ein Notebook spezifischer Befehl zur Darstellung der Grafiken im Notebook
%matplotlib inline %matplotlib inline
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Wir füllen zunächst einen Vektor mit Werten, die unsere abgetastete Zeit repräsentieren. Wir füllen zunächst einen Vektor mit Werten, die unsere abgetastete Zeit repräsentieren.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
dt = 0.01 # (Abtast-)Schrittweite festlegen dt = 0.01 # (Abtast-)Schrittweite festlegen
t_start = -5 t_start = -5
t_end = 5 t_end = 5
t_array = numpy.arange(t_start, t_end, dt) # numpy.arange "tastet" den Bereich zwischen t_start und t_end mit dt ab t_array = numpy.arange(t_start, t_end, dt) # numpy.arange "tastet" den Bereich zwischen t_start und t_end mit dt ab
print(t_array) print(t_array)
``` ```
%% Output
[-5.0000000e+00 -4.9900000e+00 -4.9800000e+00 -4.9700000e+00
-4.9600000e+00 -4.9500000e+00 -4.9400000e+00 -4.9300000e+00
-4.9200000e+00 -4.9100000e+00 -4.9000000e+00 -4.8900000e+00
-4.8800000e+00 -4.8700000e+00 -4.8600000e+00 -4.8500000e+00
-4.8400000e+00 -4.8300000e+00 -4.8200000e+00 -4.8100000e+00
-4.8000000e+00 -4.7900000e+00 -4.7800000e+00 -4.7700000e+00
-4.7600000e+00 -4.7500000e+00 -4.7400000e+00 -4.7300000e+00
-4.7200000e+00 -4.7100000e+00 -4.7000000e+00 -4.6900000e+00
-4.6800000e+00 -4.6700000e+00 -4.6600000e+00 -4.6500000e+00
-4.6400000e+00 -4.6300000e+00 -4.6200000e+00 -4.6100000e+00
-4.6000000e+00 -4.5900000e+00 -4.5800000e+00 -4.5700000e+00
-4.5600000e+00 -4.5500000e+00 -4.5400000e+00 -4.5300000e+00
-4.5200000e+00 -4.5100000e+00 -4.5000000e+00 -4.4900000e+00
-4.4800000e+00 -4.4700000e+00 -4.4600000e+00 -4.4500000e+00
-4.4400000e+00 -4.4300000e+00 -4.4200000e+00 -4.4100000e+00
-4.4000000e+00 -4.3900000e+00 -4.3800000e+00 -4.3700000e+00
-4.3600000e+00 -4.3500000e+00 -4.3400000e+00 -4.3300000e+00
-4.3200000e+00 -4.3100000e+00 -4.3000000e+00 -4.2900000e+00
-4.2800000e+00 -4.2700000e+00 -4.2600000e+00 -4.2500000e+00
-4.2400000e+00 -4.2300000e+00 -4.2200000e+00 -4.2100000e+00
-4.2000000e+00 -4.1900000e+00 -4.1800000e+00 -4.1700000e+00
-4.1600000e+00 -4.1500000e+00 -4.1400000e+00 -4.1300000e+00
-4.1200000e+00 -4.1100000e+00 -4.1000000e+00 -4.0900000e+00
-4.0800000e+00 -4.0700000e+00 -4.0600000e+00 -4.0500000e+00
-4.0400000e+00 -4.0300000e+00 -4.0200000e+00 -4.0100000e+00
-4.0000000e+00 -3.9900000e+00 -3.9800000e+00 -3.9700000e+00
-3.9600000e+00 -3.9500000e+00 -3.9400000e+00 -3.9300000e+00
-3.9200000e+00 -3.9100000e+00 -3.9000000e+00 -3.8900000e+00
-3.8800000e+00 -3.8700000e+00 -3.8600000e+00 -3.8500000e+00
-3.8400000e+00 -3.8300000e+00 -3.8200000e+00 -3.8100000e+00
-3.8000000e+00 -3.7900000e+00 -3.7800000e+00 -3.7700000e+00
-3.7600000e+00 -3.7500000e+00 -3.7400000e+00 -3.7300000e+00
-3.7200000e+00 -3.7100000e+00 -3.7000000e+00 -3.6900000e+00
-3.6800000e+00 -3.6700000e+00 -3.6600000e+00 -3.6500000e+00
-3.6400000e+00 -3.6300000e+00 -3.6200000e+00 -3.6100000e+00
-3.6000000e+00 -3.5900000e+00 -3.5800000e+00 -3.5700000e+00
-3.5600000e+00 -3.5500000e+00 -3.5400000e+00 -3.5300000e+00
-3.5200000e+00 -3.5100000e+00 -3.5000000e+00 -3.4900000e+00
-3.4800000e+00 -3.4700000e+00 -3.4600000e+00 -3.4500000e+00
-3.4400000e+00 -3.4300000e+00 -3.4200000e+00 -3.4100000e+00
-3.4000000e+00 -3.3900000e+00 -3.3800000e+00 -3.3700000e+00
-3.3600000e+00 -3.3500000e+00 -3.3400000e+00 -3.3300000e+00
-3.3200000e+00 -3.3100000e+00 -3.3000000e+00 -3.2900000e+00
-3.2800000e+00 -3.2700000e+00 -3.2600000e+00 -3.2500000e+00
-3.2400000e+00 -3.2300000e+00 -3.2200000e+00 -3.2100000e+00
-3.2000000e+00 -3.1900000e+00 -3.1800000e+00 -3.1700000e+00
-3.1600000e+00 -3.1500000e+00 -3.1400000e+00 -3.1300000e+00
-3.1200000e+00 -3.1100000e+00 -3.1000000e+00 -3.0900000e+00
-3.0800000e+00 -3.0700000e+00 -3.0600000e+00 -3.0500000e+00
-3.0400000e+00 -3.0300000e+00 -3.0200000e+00 -3.0100000e+00
-3.0000000e+00 -2.9900000e+00 -2.9800000e+00 -2.9700000e+00
-2.9600000e+00 -2.9500000e+00 -2.9400000e+00 -2.9300000e+00
-2.9200000e+00 -2.9100000e+00 -2.9000000e+00 -2.8900000e+00
-2.8800000e+00 -2.8700000e+00 -2.8600000e+00 -2.8500000e+00
-2.8400000e+00 -2.8300000e+00 -2.8200000e+00 -2.8100000e+00
-2.8000000e+00 -2.7900000e+00 -2.7800000e+00 -2.7700000e+00
-2.7600000e+00 -2.7500000e+00 -2.7400000e+00 -2.7300000e+00
-2.7200000e+00 -2.7100000e+00 -2.7000000e+00 -2.6900000e+00
-2.6800000e+00 -2.6700000e+00 -2.6600000e+00 -2.6500000e+00
-2.6400000e+00 -2.6300000e+00 -2.6200000e+00 -2.6100000e+00
-2.6000000e+00 -2.5900000e+00 -2.5800000e+00 -2.5700000e+00
-2.5600000e+00 -2.5500000e+00 -2.5400000e+00 -2.5300000e+00
-2.5200000e+00 -2.5100000e+00 -2.5000000e+00 -2.4900000e+00
-2.4800000e+00 -2.4700000e+00 -2.4600000e+00 -2.4500000e+00
-2.4400000e+00 -2.4300000e+00 -2.4200000e+00 -2.4100000e+00
-2.4000000e+00 -2.3900000e+00 -2.3800000e+00 -2.3700000e+00
-2.3600000e+00 -2.3500000e+00 -2.3400000e+00 -2.3300000e+00
-2.3200000e+00 -2.3100000e+00 -2.3000000e+00 -2.2900000e+00
-2.2800000e+00 -2.2700000e+00 -2.2600000e+00 -2.2500000e+00
-2.2400000e+00 -2.2300000e+00 -2.2200000e+00 -2.2100000e+00
-2.2000000e+00 -2.1900000e+00 -2.1800000e+00 -2.1700000e+00
-2.1600000e+00 -2.1500000e+00 -2.1400000e+00 -2.1300000e+00
-2.1200000e+00 -2.1100000e+00 -2.1000000e+00 -2.0900000e+00
-2.0800000e+00 -2.0700000e+00 -2.0600000e+00 -2.0500000e+00
-2.0400000e+00 -2.0300000e+00 -2.0200000e+00 -2.0100000e+00
-2.0000000e+00 -1.9900000e+00 -1.9800000e+00 -1.9700000e+00
-1.9600000e+00 -1.9500000e+00 -1.9400000e+00 -1.9300000e+00
-1.9200000e+00 -1.9100000e+00 -1.9000000e+00 -1.8900000e+00
-1.8800000e+00 -1.8700000e+00 -1.8600000e+00 -1.8500000e+00
-1.8400000e+00 -1.8300000e+00 -1.8200000e+00 -1.8100000e+00
-1.8000000e+00 -1.7900000e+00 -1.7800000e+00 -1.7700000e+00
-1.7600000e+00 -1.7500000e+00 -1.7400000e+00 -1.7300000e+00
-1.7200000e+00 -1.7100000e+00 -1.7000000e+00 -1.6900000e+00
-1.6800000e+00 -1.6700000e+00 -1.6600000e+00 -1.6500000e+00
-1.6400000e+00 -1.6300000e+00 -1.6200000e+00 -1.6100000e+00
-1.6000000e+00 -1.5900000e+00 -1.5800000e+00 -1.5700000e+00
-1.5600000e+00 -1.5500000e+00 -1.5400000e+00 -1.5300000e+00
-1.5200000e+00 -1.5100000e+00 -1.5000000e+00 -1.4900000e+00
-1.4800000e+00 -1.4700000e+00 -1.4600000e+00 -1.4500000e+00
-1.4400000e+00 -1.4300000e+00 -1.4200000e+00 -1.4100000e+00
-1.4000000e+00 -1.3900000e+00 -1.3800000e+00 -1.3700000e+00
-1.3600000e+00 -1.3500000e+00 -1.3400000e+00 -1.3300000e+00
-1.3200000e+00 -1.3100000e+00 -1.3000000e+00 -1.2900000e+00
-1.2800000e+00 -1.2700000e+00 -1.2600000e+00 -1.2500000e+00
-1.2400000e+00 -1.2300000e+00 -1.2200000e+00 -1.2100000e+00
-1.2000000e+00 -1.1900000e+00 -1.1800000e+00 -1.1700000e+00
-1.1600000e+00 -1.1500000e+00 -1.1400000e+00 -1.1300000e+00
-1.1200000e+00 -1.1100000e+00 -1.1000000e+00 -1.0900000e+00
-1.0800000e+00 -1.0700000e+00 -1.0600000e+00 -1.0500000e+00
-1.0400000e+00 -1.0300000e+00 -1.0200000e+00 -1.0100000e+00
-1.0000000e+00 -9.9000000e-01 -9.8000000e-01 -9.7000000e-01
-9.6000000e-01 -9.5000000e-01 -9.4000000e-01 -9.3000000e-01
-9.2000000e-01 -9.1000000e-01 -9.0000000e-01 -8.9000000e-01
-8.8000000e-01 -8.7000000e-01 -8.6000000e-01 -8.5000000e-01
-8.4000000e-01 -8.3000000e-01 -8.2000000e-01 -8.1000000e-01
-8.0000000e-01 -7.9000000e-01 -7.8000000e-01 -7.7000000e-01
-7.6000000e-01 -7.5000000e-01 -7.4000000e-01 -7.3000000e-01
-7.2000000e-01 -7.1000000e-01 -7.0000000e-01 -6.9000000e-01
-6.8000000e-01 -6.7000000e-01 -6.6000000e-01 -6.5000000e-01
-6.4000000e-01 -6.3000000e-01 -6.2000000e-01 -6.1000000e-01
-6.0000000e-01 -5.9000000e-01 -5.8000000e-01 -5.7000000e-01
-5.6000000e-01 -5.5000000e-01 -5.4000000e-01 -5.3000000e-01
-5.2000000e-01 -5.1000000e-01 -5.0000000e-01 -4.9000000e-01
-4.8000000e-01 -4.7000000e-01 -4.6000000e-01 -4.5000000e-01
-4.4000000e-01 -4.3000000e-01 -4.2000000e-01 -4.1000000e-01
-4.0000000e-01 -3.9000000e-01 -3.8000000e-01 -3.7000000e-01
-3.6000000e-01 -3.5000000e-01 -3.4000000e-01 -3.3000000e-01
-3.2000000e-01 -3.1000000e-01 -3.0000000e-01 -2.9000000e-01
-2.8000000e-01 -2.7000000e-01 -2.6000000e-01 -2.5000000e-01
-2.4000000e-01 -2.3000000e-01 -2.2000000e-01 -2.1000000e-01
-2.0000000e-01 -1.9000000e-01 -1.8000000e-01 -1.7000000e-01
-1.6000000e-01 -1.5000000e-01 -1.4000000e-01 -1.3000000e-01
-1.2000000e-01 -1.1000000e-01 -1.0000000e-01 -9.0000000e-02
-8.0000000e-02 -7.0000000e-02 -6.0000000e-02 -5.0000000e-02
-4.0000000e-02 -3.0000000e-02 -2.0000000e-02 -1.0000000e-02
-1.0658141e-13 1.0000000e-02 2.0000000e-02 3.0000000e-02
4.0000000e-02 5.0000000e-02 6.0000000e-02 7.0000000e-02
8.0000000e-02 9.0000000e-02 1.0000000e-01 1.1000000e-01
1.2000000e-01 1.3000000e-01 1.4000000e-01 1.5000000e-01
1.6000000e-01 1.7000000e-01 1.8000000e-01 1.9000000e-01
2.0000000e-01 2.1000000e-01 2.2000000e-01 2.3000000e-01
2.4000000e-01 2.5000000e-01 2.6000000e-01 2.7000000e-01
2.8000000e-01 2.9000000e-01 3.0000000e-01 3.1000000e-01
3.2000000e-01 3.3000000e-01 3.4000000e-01 3.5000000e-01
3.6000000e-01 3.7000000e-01 3.8000000e-01 3.9000000e-01
4.0000000e-01 4.1000000e-01 4.2000000e-01 4.3000000e-01
4.4000000e-01 4.5000000e-01 4.6000000e-01 4.7000000e-01
4.8000000e-01 4.9000000e-01 5.0000000e-01 5.1000000e-01
5.2000000e-01 5.3000000e-01 5.4000000e-01 5.5000000e-01
5.6000000e-01 5.7000000e-01 5.8000000e-01 5.9000000e-01
6.0000000e-01 6.1000000e-01 6.2000000e-01 6.3000000e-01
6.4000000e-01 6.5000000e-01 6.6000000e-01 6.7000000e-01
6.8000000e-01 6.9000000e-01 7.0000000e-01 7.1000000e-01
7.2000000e-01 7.3000000e-01 7.4000000e-01 7.5000000e-01
7.6000000e-01 7.7000000e-01 7.8000000e-01 7.9000000e-01
8.0000000e-01 8.1000000e-01 8.2000000e-01 8.3000000e-01
8.4000000e-01 8.5000000e-01 8.6000000e-01 8.7000000e-01
8.8000000e-01 8.9000000e-01 9.0000000e-01 9.1000000e-01
9.2000000e-01 9.3000000e-01 9.4000000e-01 9.5000000e-01
9.6000000e-01 9.7000000e-01 9.8000000e-01 9.9000000e-01
1.0000000e+00 1.0100000e+00 1.0200000e+00 1.0300000e+00
1.0400000e+00 1.0500000e+00 1.0600000e+00 1.0700000e+00
1.0800000e+00 1.0900000e+00 1.1000000e+00 1.1100000e+00
1.1200000e+00 1.1300000e+00 1.1400000e+00 1.1500000e+00
1.1600000e+00 1.1700000e+00 1.1800000e+00 1.1900000e+00
1.2000000e+00 1.2100000e+00 1.2200000e+00 1.2300000e+00
1.2400000e+00 1.2500000e+00 1.2600000e+00 1.2700000e+00
1.2800000e+00 1.2900000e+00 1.3000000e+00 1.3100000e+00
1.3200000e+00 1.3300000e+00 1.3400000e+00 1.3500000e+00
1.3600000e+00 1.3700000e+00 1.3800000e+00 1.3900000e+00
1.4000000e+00 1.4100000e+00 1.4200000e+00 1.4300000e+00
1.4400000e+00 1.4500000e+00 1.4600000e+00 1.4700000e+00
1.4800000e+00 1.4900000e+00 1.5000000e+00 1.5100000e+00
1.5200000e+00 1.5300000e+00 1.5400000e+00 1.5500000e+00
1.5600000e+00 1.5700000e+00 1.5800000e+00 1.5900000e+00
1.6000000e+00 1.6100000e+00 1.6200000e+00 1.6300000e+00
1.6400000e+00 1.6500000e+00 1.6600000e+00 1.6700000e+00
1.6800000e+00 1.6900000e+00 1.7000000e+00 1.7100000e+00
1.7200000e+00 1.7300000e+00 1.7400000e+00 1.7500000e+00
1.7600000e+00 1.7700000e+00 1.7800000e+00 1.7900000e+00
1.8000000e+00 1.8100000e+00 1.8200000e+00 1.8300000e+00
1.8400000e+00 1.8500000e+00 1.8600000e+00 1.8700000e+00
1.8800000e+00 1.8900000e+00 1.9000000e+00 1.9100000e+00
1.9200000e+00 1.9300000e+00 1.9400000e+00 1.9500000e+00
1.9600000e+00 1.9700000e+00 1.9800000e+00 1.9900000e+00
2.0000000e+00 2.0100000e+00 2.0200000e+00 2.0300000e+00
2.0400000e+00 2.0500000e+00 2.0600000e+00 2.0700000e+00
2.0800000e+00 2.0900000e+00 2.1000000e+00 2.1100000e+00
2.1200000e+00 2.1300000e+00 2.1400000e+00 2.1500000e+00
2.1600000e+00 2.1700000e+00 2.1800000e+00 2.1900000e+00
2.2000000e+00 2.2100000e+00 2.2200000e+00 2.2300000e+00
2.2400000e+00 2.2500000e+00 2.2600000e+00 2.2700000e+00
2.2800000e+00 2.2900000e+00 2.3000000e+00 2.3100000e+00
2.3200000e+00 2.3300000e+00 2.3400000e+00 2.3500000e+00
2.3600000e+00 2.3700000e+00 2.3800000e+00 2.3900000e+00
2.4000000e+00 2.4100000e+00 2.4200000e+00 2.4300000e+00
2.4400000e+00 2.4500000e+00 2.4600000e+00 2.4700000e+00
2.4800000e+00 2.4900000e+00 2.5000000e+00 2.5100000e+00
2.5200000e+00 2.5300000e+00 2.5400000e+00 2.5500000e+00
2.5600000e+00 2.5700000e+00 2.5800000e+00 2.5900000e+00
2.6000000e+00 2.6100000e+00 2.6200000e+00 2.6300000e+00
2.6400000e+00 2.6500000e+00 2.6600000e+00 2.6700000e+00
2.6800000e+00 2.6900000e+00 2.7000000e+00 2.7100000e+00
2.7200000e+00 2.7300000e+00 2.7400000e+00 2.7500000e+00
2.7600000e+00 2.7700000e+00 2.7800000e+00 2.7900000e+00
2.8000000e+00 2.8100000e+00 2.8200000e+00 2.8300000e+00
2.8400000e+00 2.8500000e+00 2.8600000e+00 2.8700000e+00
2.8800000e+00 2.8900000e+00 2.9000000e+00 2.9100000e+00
2.9200000e+00 2.9300000e+00 2.9400000e+00 2.9500000e+00
2.9600000e+00 2.9700000e+00 2.9800000e+00 2.9900000e+00
3.0000000e+00 3.0100000e+00 3.0200000e+00 3.0300000e+00
3.0400000e+00 3.0500000e+00 3.0600000e+00 3.0700000e+00
3.0800000e+00 3.0900000e+00 3.1000000e+00 3.1100000e+00
3.1200000e+00 3.1300000e+00 3.1400000e+00 3.1500000e+00
3.1600000e+00 3.1700000e+00 3.1800000e+00 3.1900000e+00
3.2000000e+00 3.2100000e+00 3.2200000e+00 3.2300000e+00
3.2400000e+00 3.2500000e+00 3.2600000e+00 3.2700000e+00
3.2800000e+00 3.2900000e+00 3.3000000e+00 3.3100000e+00
3.3200000e+00 3.3300000e+00 3.3400000e+00 3.3500000e+00
3.3600000e+00 3.3700000e+00 3.3800000e+00 3.3900000e+00
3.4000000e+00 3.4100000e+00 3.4200000e+00 3.4300000e+00
3.4400000e+00 3.4500000e+00 3.4600000e+00 3.4700000e+00
3.4800000e+00 3.4900000e+00 3.5000000e+00 3.5100000e+00
3.5200000e+00 3.5300000e+00 3.5400000e+00 3.5500000e+00
3.5600000e+00 3.5700000e+00 3.5800000e+00 3.5900000e+00
3.6000000e+00 3.6100000e+00 3.6200000e+00 3.6300000e+00
3.6400000e+00 3.6500000e+00 3.6600000e+00 3.6700000e+00
3.6800000e+00 3.6900000e+00 3.7000000e+00 3.7100000e+00
3.7200000e+00 3.7300000e+00 3.7400000e+00 3.7500000e+00
3.7600000e+00 3.7700000e+00 3.7800000e+00 3.7900000e+00
3.8000000e+00 3.8100000e+00 3.8200000e+00 3.8300000e+00
3.8400000e+00 3.8500000e+00 3.8600000e+00 3.8700000e+00
3.8800000e+00 3.8900000e+00 3.9000000e+00 3.9100000e+00
3.9200000e+00 3.9300000e+00 3.9400000e+00 3.9500000e+00
3.9600000e+00 3.9700000e+00 3.9800000e+00 3.9900000e+00
4.0000000e+00 4.0100000e+00 4.0200000e+00 4.0300000e+00
4.0400000e+00 4.0500000e+00 4.0600000e+00 4.0700000e+00
4.0800000e+00 4.0900000e+00 4.1000000e+00 4.1100000e+00
4.1200000e+00 4.1300000e+00 4.1400000e+00 4.1500000e+00
4.1600000e+00 4.1700000e+00 4.1800000e+00 4.1900000e+00
4.2000000e+00 4.2100000e+00 4.2200000e+00 4.2300000e+00
4.2400000e+00 4.2500000e+00 4.2600000e+00 4.2700000e+00
4.2800000e+00 4.2900000e+00 4.3000000e+00 4.3100000e+00
4.3200000e+00 4.3300000e+00 4.3400000e+00 4.3500000e+00
4.3600000e+00 4.3700000e+00 4.3800000e+00 4.3900000e+00
4.4000000e+00 4.4100000e+00 4.4200000e+00 4.4300000e+00
4.4400000e+00 4.4500000e+00 4.4600000e+00 4.4700000e+00
4.4800000e+00 4.4900000e+00 4.5000000e+00 4.5100000e+00
4.5200000e+00 4.5300000e+00 4.5400000e+00 4.5500000e+00
4.5600000e+00 4.5700000e+00 4.5800000e+00 4.5900000e+00
4.6000000e+00 4.6100000e+00 4.6200000e+00 4.6300000e+00
4.6400000e+00 4.6500000e+00 4.6600000e+00 4.6700000e+00
4.6800000e+00 4.6900000e+00 4.7000000e+00 4.7100000e+00
4.7200000e+00 4.7300000e+00 4.7400000e+00 4.7500000e+00
4.7600000e+00 4.7700000e+00 4.7800000e+00 4.7900000e+00
4.8000000e+00 4.8100000e+00 4.8200000e+00 4.8300000e+00
4.8400000e+00 4.8500000e+00 4.8600000e+00 4.8700000e+00
4.8800000e+00 4.8900000e+00 4.9000000e+00 4.9100000e+00
4.9200000e+00 4.9300000e+00 4.9400000e+00 4.9500000e+00
4.9600000e+00 4.9700000e+00 4.9800000e+00 4.9900000e+00]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Wir definieren nun unsere Funktionen $x(t),\:g(t)$ und $f(t)$ Wir definieren nun unsere Funktionen $x(t),\:g(t)$ und $f(t)$
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
def x(t_array): def x(t_array):
ergebnis = [] ergebnis = []
for t in t_array: for t in t_array:
if 0 <= t < 1: if 0 <= t < 1:
ergebnis.append(2) ergebnis.append(2)
else: else:
ergebnis.append(0) ergebnis.append(0)
return ergebnis return ergebnis
def f(t_array): def f(t_array):
ergebnis = [] ergebnis = []
for t in t_array: for t in t_array:
if 0 <= t < 2: if 0 <= t < 2:
ergebnis.append(1) ergebnis.append(1)
else: else:
ergebnis.append(0) ergebnis.append(0)
return ergebnis return ergebnis
def g(t_array): def g(t_array):
ergebnis = [] ergebnis = []
for t in t_array: for t in t_array:
if t >= 0: if t >= 0:
ergebnis.append(numpy.exp(-t)) ergebnis.append(numpy.exp(-t))
else: else:
ergebnis.append(0) ergebnis.append(0)
return ergebnis return ergebnis
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Wir stellen nun unsere Funktionen in Grafiken dar. Wir stellen nun unsere Funktionen in Grafiken dar.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
pyplot.plot(t_array, x(t_array), 'b') pyplot.plot(t_array, x(t_array), 'b')
pyplot.xlabel('t') # Beschriftung der x-Achse pyplot.xlabel('t') # Beschriftung der x-Achse
pyplot.ylabel('x') # Beschriftung der y-Achse pyplot.ylabel('x') # Beschriftung der y-Achse
pyplot.ylim(-1, 3) # Achsenbereiche festlegen pyplot.ylim(-1, 3) # Achsenbereiche festlegen
pyplot.title('Eingangsfunktion') # Titel der Abbildung pyplot.title('Eingangsfunktion') # Titel der Abbildung
pyplot.show() # Der Plot muss eingeblendet werden pyplot.show() # Der Plot muss eingeblendet werden
``` ```
%% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
pyplot.plot(t_array, g(t_array), 'g') pyplot.plot(t_array, g(t_array), 'g')
pyplot.xlabel('t') pyplot.xlabel('t')
pyplot.ylabel('g') pyplot.ylabel('g')
pyplot.ylim(-1, 3) pyplot.ylim(-1, 3)
pyplot.title('g(t)') pyplot.title('g(t)')
pyplot.show() pyplot.show()
``` ```
%% Output
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
pyplot.plot(t_array, f(t_array), 'r') pyplot.plot(t_array, f(t_array), 'r')
pyplot.xlabel('t') pyplot.xlabel('t')
pyplot.ylabel('f') pyplot.ylabel('f')
pyplot.ylim(-1, 3) pyplot.ylim(-1, 3)
pyplot.title('f(t)') pyplot.title('f(t)')
pyplot.show() pyplot.show()
``` ```
%% Output
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
### Faltung ### Faltung
Wir definieren die Faltung als Funktion, wobei wir als Eingabeparameter das Zeitarray sowie die beiden zu faltenden Funktionen benötigen. Wir definieren die Faltung als Funktion, wobei wir als Eingabeparameter das Zeitarray sowie die beiden zu faltenden Funktionen benötigen.
Zur Erinnerung nochmals die Faltung:
$$
x(t)*g(t)=\int_{0}^{t}x(\tau)g(t-\tau)\mathrm{d}t
$$
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
# Vorbereitung für die Plots # Vorbereitung für die Plots
import ipywidgets # Benötigt für den Schieberegler import ipywidgets # Benötigt für den Schieberegler
def faltung(t_array, x, f): def faltung(t_array, x, f):
ergebnis = [] ergebnis = []
x_ergebnis = x(t_array) x_ergebnis = x(t_array)
for t in t_array: for t in t_array:
f_ergebnis = f(t-t_array) f_ergebnis = f(t-t_array)
sum = 0 sum = 0
for i in range(0,len(t_array)): for i in range(0,len(t_array)):
sum += x_ergebnis[i]*f_ergebnis[i]*dt sum += x_ergebnis[i]*f_ergebnis[i]*dt
ergebnis.append(sum) ergebnis.append(sum)
# tau_array = t_array.copy() # tau_array = t_array.copy()
# for i in range(0,len(t_array)): # for i in range(0,len(t_array)):
# t = t_array[i] # t = t_array[i]
# sum = 0 # sum = 0
# for tau in tau_array: # for tau in tau_array:
# sum += x([tau])[0]*f([t-tau])[0] # sum += x([tau])[0]*f([t-tau])[0]
# ergebnis.append(sum) # ergebnis.append(sum)
return ergebnis return ergebnis
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
%matplotlib notebook %matplotlib notebook
# Wir führen die Faltung einmalig aus, um Rechenleistung zu sparen # Wir führen die Faltung einmalig aus, um Rechenleistung zu sparen
faltung_ergebnis = faltung(t_array, x, f) faltung_ergebnis = faltung(t_array, x, f)
# Definieren einen Schieberegler # Definieren einen Schieberegler
slider = ipywidgets.IntSlider(min=0, max=len(t_array)-1, step=1) slider = ipywidgets.IntSlider(min=0, max=len(t_array)-1, step=1)
# Wir initiieren den Plot mit 2 Reihen und einer Spalte und bekommen für jeden Subplot ein Achsen-Objekt # Wir initiieren den Plot mit 2 Reihen und einer Spalte und bekommen für jeden Subplot ein Achsen-Objekt
figure, (axis1, axis2) = pyplot.subplots(2, 1) figure, (axis1, axis2) = pyplot.subplots(2, 1)
# Wir definieren hier die Funktion die nach einer Änderung am Slider ausgeführt werden soll # Wir definieren hier die Funktion die nach einer Änderung am Slider ausgeführt werden soll
def slider_return(i): def slider_return(i):
axis1.cla() # Wir löschen den vorherigen Inhalt axis1.cla() # Wir löschen den vorherigen Inhalt
axis2.cla() axis2.cla()
axis2.set_xlim(t_array[0],t_array[-1]) # Setzen ein Achsenlimit in x und y Richtung axis2.set_xlim(t_array[0],t_array[-1]) # Setzen ein Achsenlimit in x und y Richtung
axis2.set_ylim(numpy.min(faltung_ergebnis)-0.1,numpy.max(faltung_ergebnis)+0.1) axis2.set_ylim(numpy.min(faltung_ergebnis)-0.1,numpy.max(faltung_ergebnis)+0.1)
axis2.plot(t_array[0:i], faltung_ergebnis[0:i]) # Und stellen die Ergebnisse dar axis2.plot(t_array[0:i], faltung_ergebnis[0:i]) # Und stellen die Ergebnisse dar
axis1.plot(t_array, x(t_array)) axis1.plot(t_array, x(t_array))
axis1.plot(t_array, f(-t_array+t_array[i])) axis1.plot(t_array, f(-t_array+t_array[i]))
figure.show() figure.show()
ipywidgets.interact(slider_return, i=slider) # Trägt die Informationen zusammen und erstellt den Schieberegler ipywidgets.interact(slider_return, i=slider) # Trägt die Informationen zusammen und erstellt den Schieberegler
``` ```
%% Output
<function __main__.slider_return(i)>
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Nun betrachten wir uns die Funktion `scipy.signal.convolve`. Nun betrachten wir uns die Funktion `scipy.signal.convolve`.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
%matplotlib inline %matplotlib inline
from scipy.signal import convolve from scipy.signal import convolve # Wir importieren die Funktion 'convolve' aus dem Submodul 'signal' aus dem Paket 'scipy'
# Mehr Infos zum Paket scipy unter https://www.scipy.org/
x_result = x(t_array) x_ergebnis = x(t_array)
f_result = f(t_array) f_ergebnis = f(t_array)
g_result = g(t_array) g_ergebnis = g(t_array)
pyplot.plot(t_array, convolve(x_result, f_result, mode='same')) pyplot.plot(t_array, convolve(x_ergebnis, f_ergebnis, mode='same'))
pyplot.show() pyplot.show()
``` ```
%% Output
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment