As I am newbie to signals, I have collected an appliance signal in frequency domain as follows: enter image description here

(PSD- Power Spectral Density). So, I need to calculate the SNR (Signal to Noise Ratio) and BER (Bit Error Rate) caused by this signal in Powerline Calculation. So, I have made these codes in Matlab, but what I am stuck with is calculating the SNR and BER.

bits=10000; %number of bit
b=randi([0,1],1,bits); % generate random [0,1]
t=0:1/30:1-1/30; % Time period allocated for the signal

%ASK Carrier Signals
carrier_signa_l= sin(2*pi*t);
carrier_signa_l=carrier_signa_l/sqrt(E1); %unit energy 
carrier_signal_0 =0 * sin(2*pi*t); % zeros for 0 bits in the carrier signal

for i=1:bits
    if b(i)==1 % If bit = 1
        ask=[ask carrier_signa_l];
        ask=[ask carrier_signal_0];
  • $\begingroup$ 1) You have to give the waveform of the "noise"; i.e. turn the appliance off. Or if the noise is part of the appliance then a more in-depth analysis must be done. $\endgroup$
    – rrogers
    Aug 7 '18 at 19:26
  • $\begingroup$ @rrogers I think the noise waveform can be as a white Gaussian noise. I don't know if this is what you meant by noise waveform. could you please elaborate more? $\endgroup$ Aug 8 '18 at 14:46
  • $\begingroup$ Well, what does the frequency spectrum look like; signal bandwidth and noise bandwidth? Does it have 1/f noise or "pink noise"? What do you consider "signal". Actually, there is a difference between: "real noise" due to electronics, interfering signals/events. Interferences are things like things banging because of the appliance operation. External things are probably not useful whereas things banging inside the appliance would be pertinent. What I picture is a microphone on an "appliance". Is this wrong? But it doesn't make sense to worry about BER in that case? $\endgroup$
    – rrogers
    Aug 9 '18 at 18:09

If it is a sinusoidal signal, there will be peak (among the frequency bins) in the frequency spectrum corresponding to the tone's frequency.

Ratio of the magnitude of this peak to the sum of the magnitudes of all other bins (which are noise) correspond to Signal to Noise Ratio.

But when its a non sinusoidal signal (like the one in your plot) you have to consider the relevant band of the signal instead of a single peak. you can quantify it by specifying a frequency bin corresponding to the mojor frquency component in the signal plus some leakage (related to bandwidth) into the nearby bins.

Please take a look in the following matlab code.

N               = 8192; % FFT length
leak            = 50; 
% considering a leakage of signal energy to 50 bins on either side of major freq component

fft_s           = fft(inptSignal,N); % analysing freq spectrum
abs_fft_s       = abs(fft_s);

[~,p]           = max(abs_fft_s(1:N/2));
% Finding the peak in the freq spectrum

sigpos          = [p-leak:p+leak N-p-leak:N-p+leak];
% finding the bins corresponding to the signal around the major peak
% including leakage

sig_pow         = sum(abs_fft_s(sigpos)); % signal power = sum of magnitudes of bins conrresponding to signal
abs_fft_s([sigpos]) = 0; % making all bins corresponding to signal zero:==> what ever that remains is noise 
noise_pow       = sum(abs_fft_s); % sum of rest of componenents == noise power

SNR             = 10*log10(sig_pow/noise_pow);
  • $\begingroup$ thanks for your response, I was trying to understand the relation between sig_pow and noise_pow. So is the inputSignal the appliance noise on the graph? or is it carrier_signa_l in my code? because I couldn't find the relation between them. The noise for me is the appliance on the graph above, while the signal power is my carrier_signa_l. $\endgroup$ Aug 12 '18 at 23:20
  • $\begingroup$ also, if I create a random gaussian noise to my channel, can I calculate SNR to the signal as follows? for snr_deg=1:20 askn=awgn(ask,snr_deg); for i=1:bits fft_noise = fft(askn,N); % analysing noise freq spectrum abs_fft_noise= abs(fft_noise); [~,peak_noise] = max(abs_fft_noise(1:N/2)); noisepos = [peak_noise-leak:peak_noise+leak N-peak_noise-leak:N-peak_noise+leak]; abs_fft_noise([noisepos]) = 0; noise_power = sum(abs_fft_noise); SNR = 10*log10(sig_pow/noise_power ); end $\endgroup$ Aug 12 '18 at 23:58
  • $\begingroup$ I know I have too many questions, but bear with me please, How can I detect BER from the given SNR? $\endgroup$ Aug 12 '18 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.