Date: Jan 6, 2013 1:03 PM
Author: anyone
Subject: Re: SNR script to run using Matlab
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 = S.td;

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

approximation.

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