2
$\begingroup$

I am working on noise cancellation in ecg signal and I want to calculate the Signal to noise ratio(SNR) before applying filter to the signal and after applying filter i.e., snr_before and snr_after. I used the following commands:

snr_before = mean(input_or_desired_signal.^2)/mean(noise_signal.^2);
residual_noise = desired_signal - filtered_output_signal; 
snr_after = mean( desired_signal .^ 2 ) / mean( residual_noise .^ 2 ); 

The code works as no error is generated. But only the box is displayed when I plot d same in each case and no graph is generated.. Pls help Thanks in advance..

$\endgroup$
  • $\begingroup$ It's not clear what do you ask. Is your question about how to calculate SNR or how to plot something? $\endgroup$ – Gluttton Mar 22 '15 at 9:31
  • $\begingroup$ @Gluttton Actually, I tried to plot SNR before filtering my signal and after that. The code works completely fine as it runs when I simulate it. A figure for SNR is generated but it is empty... Since no plot or graph is generated. M doing it for( i )iterations. This is the actual problem, an empty figure... I can't find out the reason. Is the code that I'm using correct? $\endgroup$ – me001 Mar 23 '15 at 12:44
  • $\begingroup$ snr_before = mean(input_or_desired_signal.^2)/mean(noise_signal.^2); residual_noise = desired_signal - filtered_output_signal; snr_after = mean( desired_signal .^ 2 ) / mean( residual_noise .^ 2 ); $\endgroup$ – me001 Mar 23 '15 at 12:46
  • $\begingroup$ Are snr_before and snr_after scalar values or matrices (vectors)? I think they are scalar values, so they are just two digits and couldn’t be plotted as lines. $\endgroup$ – Gluttton Mar 23 '15 at 12:53

Your Answer

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

Browse other questions tagged or ask your own question.