2014-04-08 86 views
0

我想了解我的项目中音频文件的MSE和PSNR的值。到目前为止,我写的代码如下:matlab中音频信号的PSNR

[y1,fs1, nbits1,opts1]=wavread('one.wav'); 
[y2,fs2, nbits2,opts2]=wavread('newOne.wav'); 
[c1x,c1y]=size(y1); 
[c2x,c2y]=size(y1); 
if c1x ~= c2x 
    disp('dimeonsions do not agree'); 
else 
R=c1x; 
C=c1y; 
err = (((y1-y2).^2)/(R*C)); 
MSE=sqrt(err); 
MAXVAL=65535; 
    PSNR = 20*log10(MAXVAL/MSE); 
    disp(['mse=' num2str(MSE) ' PSNR=' num2str(PSNR)]); 
end 

,但我如下收到错误:

矩阵的

尺寸被连接起来并不一致。

我在做什么错?

回答

3

您需要总和误差平方以计算MSE - 变化:

err = (((y1-y2).^2)/(R*C)); 

到:

err = sum((y1-y2).^2)/(R*C); 
+1

它的工作奇妙。非常感谢。 –