2

我很难理解生成 SNR (db) vs MSE 图背后的逻辑。通过改变噪声功率产生不同的信噪比 (SNR)。TMSE 的公式是独立运行的平均值。

对于每一个SNR,我生成NEval = 10 time series. 当 SNR 在 = [0:5:50] 范围内时,如何正确绘制 SNR 与 MSE 的关系图?下面是伪代码。

 N = 100; %Number_data_points
NEval = 10; %Number_of_different_Signals
Snr = [0:5:50];
T = 1000; %Number of independent runs

MSE = [1];
for I = 1:T
 for snr = 1: length(Snr)
   for expt = 1:NEval
    %generate signal
      w0=0.001;  phi=rand(1);
    signal = sin(2*pi*[1:N]*w0+phi); 
    % add zero mean Gaussian noise
    noisy_signal = awgn(signal,Snr(snr),'measured');
    % Call Estimation algorithm
    %Calculate error
    end
  end
end

plot(Snr,MSE); %Where and how do I calculate this MSE
4

1 回答 1

0

正如这里(http://www.mathworks.nl/help/vision/ref/psnr.html)或其他类似来源所解释的,MSE 只是原始信号和损坏信号之间的均方误差。在你的符号中,

w0=0.001;
signal = sin(2*pi*[1:N]*w0);
MSE = zeros(T*Neval,length(Snr));
for snr = 1:length(Snr)
    for I = 1:T*Neval     %%note, T and Neval play the same role in your pseudo code
        noisy_signal = awgn(sin(2*pi*[1:N]*w0+rand(1)),Snr(snr),'measured');
        MSE(I,snr) = mean((noisy_signal - signal).^2);
    end
end
semilogy(Snr, mean(MSE))  %%to express MSE in the log (dB-like) units

对于不同长度信号的情况:

w0=0.001;
Npoints = [250,500,1000];    
MSE = zeros(T,length(Npoints),length(Snr));
for snr = 1:length(Snr)
  for ip = 1:length(Npoints) 
    signal = sin(2*pi*[1:Npoints(ip)]*w0);
    for I = 1:T
        noisy_signal = awgn(sin(2*pi*[1:Npoints(ip)]*w0+rand(1)),Snr(snr),'measured');
        MSE(I,ip,snr) = mean((noisy_signal - signal).^2);
    end
  end
end
semilogy(Snr, squeeze(mean(mean(MSE,1),2)) )
于 2014-10-28T23:26:37.343 回答