Reputation: 3
I am working on calculating the SNR of given signals.
length = linspace(-2*pi,2*pi);
signal_1 = sin(length);
plot(signal_1);
noise_1 = 0.5*rand(size(signal_1));
plot(noise_1);
snr_22 = snr(signal_1,noise_1);
But it shows only the noise figure (attached below) whenever I run this, nothing else. But it should also show signal figures and SNR in decibels. Can anyone help me out? I am using Matlab R2015b.
Upvotes: 0
Views: 850
Reputation: 18187
As the documentation on snr()
shows:
snr(___)
with no output arguments plots the spectrum of the signal in the current figure window and labels its main features. It uses different colors to draw the fundamental component, the DC value and the harmonics, and the noise. The SNR appears above the plot. This functionality works for all syntaxes listed above exceptsnr(x,y)
.
emphasis mine.
In other words, call figure; snr(signal_1,noise_1, __);
, i.e. with at least one other input argument and no output argument, at the end of your code to have the spectrum appear. Otherwise, take a look at the contents of snr_22
and plot it by hand.
Upvotes: 1