回声系统设计
这是信号课设内容的第一个,因为当时是用word写的,公式并不能直接生成latex格式,所以有些公式多的直接采用pdf格式上传了,尽量把代码另外粘贴出来了(绝不是因为我懒),主要的都是matlab语言
1 2 3 4 5 6
| h=[1 0.5 0 0.6]; x=[1 2 -1 ]; y=conv(h,x); n=0:1:length(y)-1; stem(n,y,'filled','red')
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| x = [1 2 -1]; h = [1 0.5 0 0.6]; x0 = [ x,zeros(1,length(h)-1)]; h0 = [zeros(1,length(x)-1), flip(h)]; n = length(x0) ; n0 = 0:1:n-1; y = zeros(1,n); for i = 1:n
y(i) = sum( x0(1:i).*h0(end-i+1:end));
end stem(n0,y,'red')
|
1 2 3 4 5 6 7 8 9 10 11
| function y = delta (t) for i =1 : length(t) if t(i) == 0 y(i) = 1; else y(i) =0; end end
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| clear,clc,close all;
fs=8000; duration=3;
myrecording = audiorecorder; fprintf('Speaking for %d seconds. \n',duration); disp('Start speaking.') recordblocking(myrecording, duration); disp('End of Recording.'); x = getaudiodata(myrecording);
filename0='chushiyin2.wav'; audiowrite(filename0,x,fs);
n=length(x); duration=n/fs;
t=[0:1/fs:duration]'; h = 1*delta(t-0.2) + 0.8*delta(t-0.4) + 0.6*delta(t-0.6) + ... 0.4*delta(t-0.8) + 0.2*delta(t-1.0);
y=conv(x,h); k=audioplayer(y,fs); play(k);
filename = 'huiyin2.wav'; audiowrite(filename,y,fs); subplot(211); plot (x) ; title('原始音'); subplot(212); plot (y); title('回音');
|