# -*- coding: utf-8 -*- """ Created on Thu May 10 10:11:06 2018 @author: Student """ from pylab import * from numpy import * from matplotlib import * from scipy import * def cosinus(a,b,n): t=linspace(a,b,n) y=20+sin(2*pi*50*t) return y funkcja = cosinus(0,0.1,200) print(funkcja) t=linspace(0,0.1,200) subplot(311) plt.plot(t,funkcja,'r') def dct(x): N=x.shape[0] y=empty(N) for k in range (0,N-1): y[k]=0 for n in range(0,N-1): y[k]+=x[n]*cos(pi/N*(n+0.5)*float(k)) return y funkcja1=dct(funkcja) print(funkcja1) subplot(312) plt.plot(t,funkcja1,'r') def idct(x): N=x.shape[0] y=empty(N) for k in range (0,N-1): y[k]=0.5*x[0] for n in range(0,N-1): y[k]+=x[n]*cos(pi/N*(n+0.5)*float(k)) return y funkcja2=idct(funkcja) print(funkcja2) subplot(313) plt.plot(t,funkcja2,'r')