Skip to content
Snippets Groups Projects
Commit e1937de3 authored by Sadikni, Remon's avatar Sadikni, Remon
Browse files

Upload New File

parent 7952978f
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# Plotting
%% Cell type:markdown id: tags:
- pylab enthält Plotting Funktionen und auch Arrays, die wir brauchen, um die Höhe des Balls in Abhängigkeit von der Zeit abzubilden.
- Arrays enthalten eine Liste von Zahlen, z.B. [0 1 2 3 4 5 6 7 8 9]
- linspace(min, max, n) erzeugt ein Array von n Zahlen zwischen min und max.
- um einen Plot zu erzeugen, braucht man ein eindimensionales Array für die x-Achse und eins für die y-Achse.
- dann wird für jedes Paar aus x und y ein Punkt im Plot abgebildet
- und diese Punkte werden durch Geraden verbunden
%% Cell type:markdown id: tags:
## Diagonale plotten
- erst einmal plotten wir eine Diagonale
- dazu brauchen wir ein x-Array und ein y-Array, beide der Form [0 1 2 3 4 5 6 7 8 9]
%% Cell type:code id: tags:
``` python
from pylab import *
x = array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
y = array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
xlabel("x")
ylabel("y")
plot(x,y,"x")
show()
```
%% Output
%% Cell type:markdown id: tags:
## Flugkurve eines Balls
jetzt plotten wir die Flugkurve eines Balls mit einer bestimmten Anfangsgeschwindigkeit v0
%% Cell type:code id: tags:
``` python
from pylab import * # importiert plotting und array Funktionen
v0 = 5 # initial velocity
g = 9.81 # acceleration of gravity
n = 11 # number of points
t = linspace(0, 2*v0/g, n)
print(t)
```
%% Output
[0. 0.1019368 0.2038736 0.3058104 0.4077472 0.509684
0.6116208 0.71355759 0.81549439 0.91743119 1.01936799]
%% Cell type:code id: tags:
``` python
y = v0*t - 0.5*g*t**2
print(y)
```
%% Output
[0. 0.09989806 0.19571865 0.28746177 0.37512742 0.4587156
0.5382263 0.61365953 0.68501529 0.75229358 0.81549439 0.87461774
0.92966361 0.98063201 1.02752294 1.07033639 1.10907238 1.14373089
1.17431193 1.20081549 1.22324159 1.24159021 1.25586137 1.26605505
1.27217125 1.27420999 1.27217125 1.26605505 1.25586137 1.24159021
1.22324159 1.20081549 1.17431193 1.14373089 1.10907238 1.07033639
1.02752294 0.98063201 0.92966361 0.87461774 0.81549439 0.75229358
0.68501529 0.61365953 0.5382263 0.4587156 0.37512742 0.28746177
0.19571865 0.09989806 0. ]
%% Cell type:code id: tags:
``` python
plot(t, y)
xlabel("t")
ylabel("y")
show()
```
%% Output
%% Cell type:markdown id: tags:
## Aufgaben
- Schreibe an die y Achse "Ballposition in Meter"
- Plotte eine Diagonale die von links oben nach rechts unten geht.
- Plotte eine Gerade, die parallel zu x Achse verläuft
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment