【问题标题】:Times Matrix dimensions must agree in matlab时间矩阵尺寸必须在 matlab 中一致
【发布时间】:2015-12-25 11:04:19
【问题描述】:

我需要录制音频信号,然后将其转换为频谱形式,然后对其进行过滤。

这就是我记录信号并将其转换为频谱的方式:

        % 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);

【问题讨论】:

  • 你在哪一行得到这个错误?
  • @dfri 当我使用此行进行过滤时:y=x.*xf;

标签: matlab signals communication


【解决方案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 向量)。希望它对你有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-12
    • 2011-12-05
    • 1970-01-01
    相关资源
    最近更新 更多