In [15]:
def freqchange(freq1, freq2, f_sample=40000, N=10):
"Erstellt einen Frequenzübergang Freq1 auf Freq2 mit je N Perioden Rechteckfunktion und entsprechende FFT"
freq1, freq2 = float(freq1), float(freq2)
print "Samplingfrequenz:", f_sample/1000., "kHz"
f1 = tile(concatenate((ones(f_sample/(2*freq1)), zeros(f_sample/(2*freq1))), axis=1), N)
f2 = tile(concatenate((ones(f_sample/(2*freq2)), zeros(f_sample/(2*freq2))), axis=1), N)
f = concatenate((f1, f2), axis=1)-.5
xaxis = arange(0, (N/freq1)+(N/freq2), ((N/freq1)+(N/freq2))/f.size)
print f.size
print xaxis.size
#plot(xaxis, f)
plt.xlabel('t in s')
plt.ylim(-0.5,1.5)
#figure()
FT = fft.fft(f)/f.size
faxis = fft.fftfreq(f.size, (1./f.size))
plot(faxis[:50], np.abs(FT[:50]))
#plot(faxis[:20], real(FT[:20]))
#plot(faxis[:20], imag(FT[:20]))
plt.xlabel('Freq in Hz')
#print abs(FT[])
return f;
x = freqchange(200,400, N=1)
figure()
z = freqchange(400,800, N=1)
In [ ]: