The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: SNR script to run using Matlab
Replies: 2   Last Post: Jan 6, 2013 1:03 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 26
Registered: 12/22/12
Re: SNR script to run using Matlab
Posted: Jan 6, 2013 1:03 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

while we're waiting, a few items to consider...

On Fri, 04 Jan 2013 09:27:08 +0000, Wan wrote:

> Hi,
> below is my coding:
> %<--- LOAD SIGNAL (FILENAME:mydata.mat)
> %data = ('mydata.mat')
> Fs=100;
> t= 0: 1/Fs: 20;
> S = load('mydata.mat');
> signal =;

So, you acquire your signal vector from a struct, but you don't offer any other detail about it. Absent that detail, how
do you propose to establish noise power level? Absent that, how would you go about establishing the target SNR
values (per the assignment)?

> x= signal
> SNR = 0;
> % Generate Gaussian Noise with zero mean and unit variance
> %function [y] = add_noise (signal, SNR)
> x_var=var (x);
> x_lng=length(x)
> n_var=x_var/10^(SNR/10);
> noise=n_var*randn(1,x_lng);

Usually, we want a specified noise distribution, with a target variance and around some mean value. It's not clear to
me why you want to derive a basis of that from statistics of the signal, but it won't matter as long as you can show
that statistics of noise otherwise match requirements of the assignment.

[comment lines snipped]

> %mix signal with noise
> mix = x+ noise;

> Fc = 100 ; %cut off frequency
> w = Fc/(2*Fs); % Normalized frequency
> %design a low pass fitler with above mentioned specifications
> [b,a]=butter(2,w,'low'); %5th order butterworth LPF

No, "butter(2,w,'low')" returns numerator and denominator coefficients for a 2nd-order LPF, based on the Butterworth

Seems to me you have quite a bit of research to do.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.