Slice-Operation (Schaubild)
Verfasst: Dienstag 22. Juni 2010, 15:04
Ich habe hier eine Aufgabe, bei der ich etwas hänge. Ich hoffe, ihr könnt mir n bisschen weiterhelfen. (erforderlich: numpy und pylab)
http://img251.imageshack.us/i/41151404.jpg/
Wie erzeuge ich die Darstellung nur jeden 10. Punktes in Aufgabe 2?
http://img251.imageshack.us/i/41151404.jpg/
Wie erzeuge ich die Darstellung nur jeden 10. Punktes in Aufgabe 2?
Code: Alles auswählen
print "Aufgabe 1"
from numpy import*
from pylab import*
x=linspace(-2*pi, 2*pi, 1000)
a=sin(1/x)
b=arctan(x)
c=exp((-x**2)/(2*pi))*cos(8*x)
amin=min(a)
amax=max(a)
bmax=min(b)
bmin=max(b)
cmin=min(c)
cmax=max(c)
print "Die Minimalwerte sind a) %.4f, b) %.4f und c) %.4f" % (amin, bmin, cmin)
print "Die Maximalwerte sind b) %.4f, b) %.4f und c) %.4f" % (amax, bmax, cmax)
plot(x, a, label="sin(x)")
plot(x, b, label="arctan(x)")
plot(x, c, linestyle="dotted", linewidth=2.5, label="exp((-x**2)/(2*pi))*cos(8*x)") # Funktion c) wird ab hier geplottet.
xlabel ("x")
ylabel ("y")
title("Schaubilder der Funktionen")
legend(loc="lower right")
grid()
ylim(-1.5,1.5)
xlim(-2*pi,2*pi)
sleep(1)
print
print "Aufgabe 2"
print "siehe Schaubild"
x2=linspace(-2*pi, 2*pi, 100)
a2=sin(1/x2)
figure()
plot(x, a, color="blue", linestyle="dotted", linewidth=2.5, label= "Aufgabe 1a)")
plot(x2, a2, color="red", label="Aufgabe 2)")
xlim(-.5,.5)
ylim(-.4,.4)
title("gezoomt!")
legend()
grid()
show()