<< Chapter < Page Chapter >> Page >
The MATLAB source code for the Sparse Signal Recovery in the Presence of Noise collection.

Code

The following is the MATLAB source code for each of the components of our project.

Addnoise.m

function out = addNoise(sig,mean,sd,Plot) %addNoise%adds noise with given mean and sd to the signal rand=randn(1,1000)*sd+mean;out=sig+rand; if(Plot==1)plot(1:1000,out,1:1000,sig); endend

Sample.m

function out = sample(sd,plot,sig) %sample%samples a manually constructed signal, and adds gaussian noise to it %with a standard deviation that is providedout=fft(addNoise(sig,0,sd,plot)); end

Init.m

function [out,samp]=init(sig,sd)%averages the signal and the noise over a number of samples to make the %noise level manageableout=sig+randn(1,1000).*sd; %optimize number of samplesif sd<76 val=6.25;else val=9;end samp=floor((ceil(sd))^2/(val));for n=2:samp out=(out.*(n-1)+sig+randn(1,1000).*sd)/n;end out=fft(out);end

Simpleiterate.m

function [mask, NSig,runT] = simpleIterate(sigMask,threshold,run,n,sd,sig)%simpleIterate(sigMask,threshold,run,n) %computes an iteration of the thresholding, with a running average of run,%on iteration n, with the current signal mask of sigMask %returns the new signal mask, the current signal(non-masked) NSig and the%running average of the signal runT siz=size(sigMask);temp=zeros(1,siz(2)); for i=1:4NSig=sample(sd,0,sig).*sigMask; if(n==1)runT=NSig; elserunT=(run.*(n-1)+NSig)/n; end%temp=temp+(max(abs(real(NSig)),abs(imag(NSig)))>threshold); temp=temp+(max(abs(real(runT)),abs(imag(runT)))>threshold); %temp=temp+(abs(NSig)>threshold); endmask=zeros(1,siz(2)); for l=1:siz(2)if(temp(l)<2) mask(l)=0;else mask(l)=sigMask(l);end endend

Testarbitary.m

function [flag,samples,time]=testArbitrary(sig,sd)%Simulates the transmission of a signal in the library, and tests whether %or not it can be recovered.siglib=cat(1,sin(0:pi/500:(1000*pi-1)/500),sin(0:pi/250:(2000*pi-1)/500),sin(0:pi/125:(4000*pi-1)/500),sin(0:pi/50:(10000*pi-1)/500),sin(0:pi/25:(20000*pi-1)/500)); siglib=cat(1,siglib,sin(0:pi/500:(1000*pi-1)/500)+sin(0:pi/50:(10000*pi-1)/500),cos(0:pi/500:(1000*pi-1)/500),cos(0:pi/250:(2000*pi-1)/500),cos(0:pi/125:(4000*pi-1)/500),cos(0:pi/50:(10000*pi-1)/500));siglib=cat(1,siglib,cos(0:pi/25:(20000*pi-1)/500),cos(0:pi/25:(20000*pi-1)/500)+sin(0:pi/500:(1000*pi-1)/500),sin(0:pi/500:(1000*pi-1)/500)+sin(0:pi/125:(4000*pi-1)/500)+cos(0:pi/25:(20000*pi-1)/500)); sigmax=max(abs(fft(siglib(sig,:))));threshhold=sigmax-3*max(abs(real(fft(randn(1,1000))))); tolerance=.5;A=ones(1,1000); flag=0;tic [C,samples]=init(siglib(sig,:),sd); for i=1:10000[A,B,C]=simpleIterate(A,threshhold,C,i+samples,sd,siglib(sig,:));for j=1:size(siglib) if(abs(ifft(A.*C)-siglib(j,:))<tolerance) flag=j;break; endend if(flag>0) break;end endsamples=samples+i; time=toc;end

Controller.m

function accepted = Controller(enteredpassword,sd) %Tests whether or not a transmission of a password will activate the system%This simulates the noise and processing as well as the values actualpassword=cat(1,13,5,10,4,2,8);accepted=1; redundancy=3;for i=1:size(actualpassword); flag=0;%while flag==0 for j=1:redundancy [flag,runs]=testArbitrary(enteredpassword(i),sd); endif(flag~=actualpassword(i)) accepted=-i;break; endend end

Controller2.m

function Controller2() %Helper function used to graph trendssig=1; for sd=0:30passed=0; for reps=1:50if(testArbitrary(sig,3+sd/10)==sig) passed=passed+1;end endtemp(sd*10-29)=passed endsubplot(1,1,1); plot(temp);end

Questions & Answers

Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
Jyoti Reply
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
LITNING Reply
what is a peer
LITNING Reply
What is meant by 'nano scale'?
LITNING Reply
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
Praveena Reply
hi
Loga
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, Sparse signal recovery in the presence of noise. OpenStax CNX. Dec 14, 2009 Download for free at http://cnx.org/content/col11144/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Sparse signal recovery in the presence of noise' conversation and receive update notifications?

Ask