SHOW:
|
|
- or go back to the newest paste.
1 | - | %część 1: |
1 | + | %część 2: |
2 | ||
3 | - | N=4000; |
3 | + | %[x,fpx]=wavread('/home/c/mbi04czap.wav'); |
4 | - | fp=1000; |
4 | + | [x,fpx]=audioread('/mbi04czap.wav'); |
5 | - | t=0:1/fp:(N-1)/fp; |
5 | + | Nx=length(x); |
6 | tx=0:1/fpx:(Nx-1)/fpx; | |
7 | - | %sygnał - sinusoida o zmiennej częstotliwości |
7 | + | subplot(2,2,1); |
8 | - | x=chirp(t, 100, 4.0, 400); |
8 | + | plot(tx,x); |
9 | - | subplot(3,2,1); |
9 | + | |
10 | - | plot(t,x); |
10 | + | |
11 | ||
12 | ||
13 | ||
14 | ||
15 | ||
16 | ||
17 | - | %moduł widma |
17 | + | Nfx=2^15; |
18 | - | Nf=2^12; |
18 | + | N21x=Nfx/2+1; |
19 | - | N21=Nf/2+1; |
19 | + | v=fft(x,Nfx); |
20 | - | v=fft(x,Nf); |
20 | + | |
21 | fx=linspace(0,fpx/2,N21x); | |
22 | - | f=linspace(0,fp/2,N21); |
22 | + | subplot(2,2,2); |
23 | - | subplot(3,2,2); |
23 | + | plot(fx,wx(1:N21x)); |
24 | - | plot(f,wx(1:N21)); |
24 | + | |
25 | ylabel('modul widma'); | |
26 | ||
27 | ||
28 | ||
29 | ||
30 | ||
31 | ||
32 | dr=8; | |
33 | - | %odpowiedź impulsowa |
33 | + | y=decimate(x,dr); |
34 | - | M=201; |
34 | + | Ny=length(y); |
35 | - | h=fir1(M-1,0.5); |
35 | + | fpy=fpx/dr; |
36 | - | th=0:1/fp:(M-1)/fp; |
36 | + | ty=0:1/fpy:(Ny-1)/fpy; |
37 | - | subplot(3,2,3); |
37 | + | subplot(2,2,3); |
38 | - | plot(th,h); |
38 | + | plot(ty,y); |
39 | xlabel('czas[s]') | |
40 | - | ylabel('odp. impulsowa'); |
40 | + | ylabel('sygnal po decymacji'); |
41 | ||
42 | ||
43 | ||
44 | ||
45 | ||
46 | ||
47 | ||
48 | Nfy=2^13; | |
49 | N21y=Nfy/2+1; | |
50 | v=fft(y,Nfy); | |
51 | wy=abs(v); | |
52 | fy=linspace(0,fpy/2,N21y); | |
53 | subplot(2,2,4); | |
54 | plot(fy,wy(1:N21y)); | |
55 | xlabel('czestotliwosc[Hz]'); | |
56 | ylabel('modul widma sygnalu po decymacji'); |