Matlab: Mean Square Error

6 次查看(过去 30 天)
Ali Arslan
Ali Arslan 2015-5-1
Hi I am new to Matlab and I am having difficulties understanding the logic behind Mean Square Error. I have been given a signal and I am able to generate it and calculate SNR of the signal, is there a way to find mean square error between original signal and SNR signal?
% Number of Samples.
n = 1:512;
% Given Signal
signal = exp(-5*(n-250).^2/100000).cos(pi(n-250)/6);
% Range of SNR
Snr = 30:-5:-10
% Calculate and display MSE between the original signal and noisy signal
??????
  3 个评论
Ali Arslan
Ali Arslan 2015-5-1
Hi Adam Thanks for reply I don't understand
How to calculate the error (subtraction) How to calculate the error (subtraction) Square it Please Recommend me how I can calculate mean square error here thanks
Following Code I am using
%% Generate a Noisy Signal.
% Number of Samples
n = 1:512;
% Given Signal
signal = exp(-5*(n-250).^2/100000).*cos(pi*(n-250)/6);
% Range of Signal to Noise ratio
Snr = (30:-5:-10);
for snr = 1:length(Snr)
noisy_signal = awgn(signal,Snr(snr),'measured');
end
end
figure(); plot(signal); title('Input signal'); grid on;
figure(); plot(noisy_signal); title('Signal With Noise'); grid on;
Adam
Adam 2015-5-2
I'm still not sure exactly what aspect you are struggling on.
signal - noisy_signal;
is a subtraction.
a.^2
is a squaring of the an array a.
The Mathlab documentation includes plenty of help on applying a simple mean filter to the result of that.

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2015-5-1
If you have the Image Processing Toolbox, use immse() or psnr().
  4 个评论
Ali Arslan
Ali Arslan 2015-5-2
编辑:Ali Arslan 2015-5-2
Thank you so much for helping me out.
Now I understand the concept behind it but I am still struggling to solve Mean Square Error Problem as you read in my question which I posted above, I have to calculate a mean square error between original signal and noisy signal. How can I solve this problem thanks?
Image Analyst
Image Analyst 2015-5-2
Like Adam, I'm confused why this is so complicated and confusing to you. The name tells you how to do it. Let me do it in multiple steps.
Get the error
theError = signal - noisySignal;
Square it
squaredError = theError .^ 2;
Get the mean
% Use the mean() function.
I can't do every single step for you because it sounds like homework but the last step is unbelievably trivial.
One thing to get clarification on from your instructor is if the SNR is calculated based on the maximum signal, or is is supposed to apply on a element by element basis, which means the noise on the right will be less than on the left because the signal decays.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by