采样信号
fs=1000; %设置采样频率 1k
N=500; %采样点数
t=0:1/N:1; %时间序列
x1=sin(2*pi*20*t); %信号
x2=sin(2*pi*200*t); %噪声
x=x1+x2; %信号混合
dlmwrite('test.txt', x);
subplot(251);
plot(t,x); %绘制原始信号
xlabel('时间');
ylabel('幅值');
title('原始信号');
grid on;
bin文件读取画图
fid = fopen('G:\zkss20181016\audio_mix\duibi\1\fhu1_m1.bin','rb');
[A] = fread(fid,500,'float');
t = 1:1:500;
plot(t,A) ,xlabel('时间');ylabel('幅值');
hold on
fid = fopen('G:\zkss20181016\audio_mix\duibi\2\fhu1_m1.bin','rb');
[A] = fread(fid,500,'float');
t = 1:1:500;
plot(t,A) ,xlabel('时间');ylabel('幅值');
iir滤波器测试
g = 12;
Q =1.0892;
Fs = 48000;
A = 10^(g/40);
f = 12691;
w = 2* pi * f/Fs;
sn = sin(w);
cs = cos(w);
sn1 = sin(2*w);
cs1 = cos(2*w);
a1 = sn/(2*Q);
%a0 a1 a2
c1 = (1+a1*A)/(1+a1/A);
c2 = -2*cs/(1+a1/A);
c3 = (1-a1*A)/(1+a1/A);
%b0 b1 b2
c4 = 1;
c5 = -2*cs/(1+a1/A);
c6 = (1-a1/A)/(1+a1/A);
c7 = (1+c5*cos(w) + c6*cos(2*w) )^2 + (c5*sin(w)+c6*sin(2*w))^2;%low
c8 = (c1+c2*cos(w)+c3*cos(2*w))*(1+c5*cos(w) + c6*cos(2*w) ) +(c2*sin(w)+c3*sin(2*w))*(c5*sin(w)+c6*sin(2*w));%real
c9 = (c1+c2*cos(w)+c3*cos(2*w))* (c5*sin(w)+c6*sin(2*w)) - (1+c5*cos(w) + c6*cos(2*w) )*(c2*sin(w)+c3*sin(2*w));% verturel
c10 = c8/c7;
c11 = c9/c7;
c12 = (c1+c2*cos(w)+c3*cos(2*w))-(c2*sin(w)+c3*sin(2*w))*1i;
c13 = (1+c5*cos(w)+c6*cos(2*w))-(c5*sin(w)+c6*sin(2*w))*1i;
c15 = c12/c13;