How to find MSE for different number of iterations when i have an audio signal

조회 수: 60(최근 30일)
Martina Pammelati
Martina Pammelati 2019년 8월 18일
답변: Sourav Bairagya 2019년 8월 21일
I have an audio signal x with dimension 435200x2. I have to find the MSE between this signal and another audio signal of the same dimension for a number of iterations equal to 1000. How can i find it when i have large signals like in this case?

답변(1개)

Sourav Bairagya
Sourav Bairagya 2019년 8월 21일
To calculate Mean Squared Error (MSE) between the two signals, first you have to calculate the difference between the two signals i.e. error signal.
Then, calculate the element wise square of this error signal to get Squared Error.
Now, calculate mean of the Squared Error over all its elements using “mean” function to get the desired MSE.
Write this whole method inside a function named calMSE and add this to your path.
function MSE = calMSE(t1,t2)
error = t1-t2; %Error between two signal
sqrd_err = error.^2; %Taking element wise sum of the error vector
MSE = mean(sqrd_err,'all'); %use ‘all’ in mean function to mean over all the elements of
% squared error signal
end
Now you can use this function as follows:
t1 = rand(435200,2); %Creating an random signal of dimension 435200X2
t2 = rand(435200,2); %Creating another random signal of dimension 435200X2
MSE = calMSE(t1,t2); %Call calMSE function to calculate MSE between t1 & t2
Now, use this function calMSE inside a for loop to calculate MSE between two input signals for desired number of iterations.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by