Attachment 'sempr2.m'
Download 1 clc;
2 clear all;
3 close all;
4 format long;
5
6 % Nacteni signalu
7 [i,fs,b] = wavread('Sound.wav');
8 N = length(i);
9 figure; stem((0:length(i)-1)/fs,i,'.');
10 title('Vstupni signal');
11 xlabel('t[s]');
12 ylabel('s(t)');
13 grid on;
14
15 % Nacteni filtru
16 f = dlmread('filtr.dat', '\n');
17 figure; stem((0:length(f)-1)/fs,f);
18 title('Impulzova odezva filtru');
19 xlabel('t[s]');
20 ylabel('s(t)');
21 grid on;
22
23 % Konvoluce
24 o = conv(i, f);
25 wavwrite(o, fs, b, 'vystup.wav');
26 figure; stem((0:length(o)-1)/fs,o,'.');
27 title('Vystupni signal');
28 xlabel('t[s]');
29 ylabel('s(t)');
30 grid on;
31
32 % Spektrum vstupniho signalu
33 is = fftshift(fft(i));
34 figure; stem((-length(is)/2:length(is)/2-1)*fs/length(i),abs(is),'.');
35 title('Spektrum vstupniho sugnalu');
36 xlabel('f[Hz]');
37 ylabel('S(f)');
38
39 % Spektrum vystupniho signalu
40 os = fftshift(fft(o));
41 figure; stem((-length(os)/2:length(os)/2-1)*fs/length(o),abs(os),'.');
42 title('Spektrum vystupniho signalu');
43 xlabel('f[Hz]');
44 ylabel('S(f)');
45
46 % Energie vstupu a vystupu
47 Ein = sumsqr(i)
48 Eout = sumsqr(o)
49
50 return;
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.