Question

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??

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top