PSNR for audio signal in matlab

柔情痞子 提交于 2019-12-25 02:51:15

问题


I am trying to find out the values of MSE and PSNR for audio files in my project. The code i have written so far is as follows:

[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

but i am getting error as follows:

Dimensions of matrices being concatenated are not consistent.

what am i doing wrong??


回答1:


You need to sum the squared errors in order to calculate MSE - change:

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

to:

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


来源:https://stackoverflow.com/questions/22935900/psnr-for-audio-signal-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!