我需要录制音频信号,然后将其转换为频谱格式,然后对其进行过滤。
这就是我如何录制我的信号&将其转换为频谱:
% Record your voice for 10 seconds.
recObj = audiorecorder;
disp('Start speaking.')
recordblocking(recObj,10);
disp('End of Recording.');
% Play back the recording.
play(recObj);
% Store data in double-precision array.
myRecording = getaudiodata(recObj);
% Plot the waveform.
figure
plot(myRecording);
fs = 48000;
% get the spectrum.
x=myRecording;
xf=fftshift(fft(x)*(1/fs));
figure
plot(real(xf));
现在我想过滤任何大于4k的光谱 我用了一个零和一个零理想过滤的 但它总是给我(时间 矩阵尺寸必须达成一致)。而且我不知道如何解决它!
% Here is my Ideal filter
n1=-80000:-4000;
n2=-4000:4000;
n3=4000:80000;
n=[n1 n2 n3];
x1=zeros(1,length(n1));
x2=ones(1,length(n2));
x3=zeros(1,length(n3));
x=[x1 x2 x3];
y=x.*xf;
figure
plot(n,y);
答案 0 :(得分:1)
原因是你的xf矢量有80000个元素,而n1 + n2 + n3 = 160003。
尝试替换
n1=-80000:-4000;
n2=-4000:4000;
n3=4000:80000;
n=[n1 n2 n3];
带
n1=-39999:-4001;
n2=-4000:4000;
n3=4001:40000;
n=[n1 n2 n3];
和
x=[x1 x2 x3];
带
x=[x1 x2 x3]';
(你必须转置x向量)。希望它适合你。