Fs = 44100; %音频信号采样率 dt = 1.0/Fs; %采样周期 T = 4; %声音播放长度为4秒 N = T/dt; %采样点数 t = [0:N-1]*dt; %时间向量 x = 0.3*sin(2*pi*300*t); 00Hz音频信号
subplot(2,2,1) plot(t,x); %画图 axis([0,0.01,-0.5,0.5]); %调整数轴 p1=audioplayer(x,Fs); %声音播放 play(p1)
pause(5) y1 = 0.1*randn(1,length(t)); %高斯白噪声生成 subplot(2,2,2) plot(t,y1); axis([0,0.01,-0.5,0.5]); p2=audioplayer(y1,Fs); play(p2)
subplot(2,2,3) hist(y1,100);
y2=x + y1; subplot(2,2,4) plot(t,y2); axis([0,0.01,-0.5,0.5]); p4=audioplayer(y2,Fs); play(p4)