Matlab程序运行出错怎么修改clc;fs=8000; x1=wavread('ding.wav');t=(0:length(x1)-1)/8000;f=fs*(0:1023)/2048;Au=0.05;d=[Au*cos(2*pi*3800*t)]'; %噪声为3.8kHz的余弦信号x2=x1+d;y1=fft(x1,2048); y2=fft(x2,2048);figure(1)plot(t,x2)grid on;ax
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 09:35:31
Matlab程序运行出错怎么修改clc;fs=8000; x1=wavread('ding.wav');t=(0:length(x1)-1)/8000;f=fs*(0:1023)/2048;Au=0.05;d=[Au*cos(2*pi*3800*t)]'; %噪声为3.8kHz的余弦信号x2=x1+d;y1=fft(x1,2048); y2=fft(x2,2048);figure(1)plot(t,x2)grid on;ax
Matlab程序运行出错怎么修改
clc;
fs=8000;
x1=wavread('ding.wav');
t=(0:length(x1)-1)/8000;
f=fs*(0:1023)/2048;
Au=0.05;
d=[Au*cos(2*pi*3800*t)]'; %噪声为3.8kHz的余弦信号
x2=x1+d;
y1=fft(x1,2048);
y2=fft(x2,2048);
figure(1)
plot(t,x2)
grid on;axis tight;
title('加噪后的信号');
xlabel('time(s)');
ylabel('幅度');
figure(2)
subplot(2,1,1);
plot(f,abs(y1(1:1024)));grid on;axis tight;
title('原始语音信号频谱');
xlabel('Hz');ylabel('幅度');
subplot(2,1,2);
plot(f,abs(y2(1:1024)));grid on;axis tight;
title('加噪语音信号频谱');
xlabel('Hz');ylabel('幅度');
运行后出现
Error using ==> unknown
Matrix dimensions must agree.
Error in ==> Untitled4 at 15
x2=x1+d;
Matlab程序运行出错怎么修改clc;fs=8000; x1=wavread('ding.wav');t=(0:length(x1)-1)/8000;f=fs*(0:1023)/2048;Au=0.05;d=[Au*cos(2*pi*3800*t)]'; %噪声为3.8kHz的余弦信号x2=x1+d;y1=fft(x1,2048); y2=fft(x2,2048);figure(1)plot(t,x2)grid on;ax
矩阵的维数不对,你看一下x1维数和d的是否是一样的,要相同可以相加的,后者说d转置的维数和x1是否相同