版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、30 eginnersCodeforCompressiveSensingAlejandroWeinsteinSeptember2009SparseSignalsintheTimeDomain1.1UsingaRandomSensingMatrixInthisfirstexamplewewillmeasureasignalthatissparseinthetimedomain.Wewillusearandomsensingmatrix,andwewillsolvetherecoveryproblemusingthel1-Magictoolbox.Weusethefollowingfunction
2、stogeneratethesignalsandthesensingmatrix:Listing1:Sparsesignalandrandommeasurementmatrix.functionf=getsparsefun(n,s)tmp=randperm(n);f=zeros(n,1);f(tmp(1:s)=randn(s,1);functionA=getArandom(n,m)A=sqrt(1/m)*randn(m,n);Thefollowingscriptusethesefunctionstogeneratethesignal,takethemeasurementsanddotherec
3、overy.Figure1showstheresult.Listing2:Example1.1234567891011121314151617181920212223242526272829%CSexample1Sensingmatrixphiisrandom.RepresentationbasisPsiistheRecoveringusingl1magic.2;s15*525=nsm%SignallengthSparsitylevelNumberofmeasurementsf=getsparsefun(n,s);A=getArandom(n,m);y=A*f;%Takethemeasurem
4、ents%Solveusingl1magic.path(path,./Optimization);x0=pinv(A)*y;%initialguess=ticxp=l1eqpd(x0,A,y,1e-3);tocnorm(f-xp)/norm(f)plot(f)holdonplot(xp,r.)legend(Original,Recovered)canonicalbasis.minenergy30 #TherecoverycanbemadebyusingCVXinsteadofl1-Magic.Justreplacelines19to24by3 -3.1111ii1I111OriginRecov
5、alered-111111I111|210-1-250100150200250300350400450500Figure1:Script1results.Listing3:UsingCVXfortherecovery.%SolveusingCVX.cvxbeginvariablexp(n);minimize(norm(xp,1);subjecttoA*xp=y;cvxend1.2UsingaFourierSensingMatrixNowwearegoingtorepeatthesameexperiment,butusingasamplingmatrixbasedontheFourierbasi
6、s.Wegeneratethemeasurementmatrixwiththefollowingfunction:Listing4:Fourierbasedmeasurementmatrix.functionA=getAfourier(n,m)tmp=randperm(n);phi=inv(fft(eye(n);A=phi(tmp(1:m/2),:);A=real(A);imag(A);Inordertorecoverthesignalusingl1-magic,nowweneedtousethefunctionl1qc_logbarrierinsteadofl1eq_pd.Ontheothe
7、rhand,thereisnoneedtochangeanythingwhensolvingtheproblemwithCVX.SinceingeneralissimplerandclearertouseCVX,weonlyusethisapproachinthefollowingexamples.SparseSignalintheFrequencyDomainLetstrynowwithasignalsparseinthefrequencydomain.Wegeneratethesignalas:Listing5:Sparsesignalinthefrequencydomain.0:n-1;
8、cos(2*pi/256*t)+cos(2*pi/128*t); 1234567891011Figure2showstheresult.Asexpected,therecoveryisexact.Letsmodifyoursignalslightly,byreplacingoneofthecosinebyasine:LetssolvewitharandomsensingmatrixandCVX.Noticethatnowweneedtospecifytherepresentationbasis(seeline5):Listing6:RandommeasurementsandCVXrecover
9、y.A=getArandom(n,m);y=A*f;%SolveusingCVX.Psi=inv(fft(eye(n);cvxbeginvariablexp(n);minimize(norm(xp,1);subjecttoA*Psi*xp=y;cvxendFigure2:Recoveryofafrequencydomainsparsesignal.Listing7:Sparsesignalinthefrequencydomain.t=0:n-1;f=cos(2*pi/256*t)+sin(2*pi/128*t);Figure3showstheresult.Evidentlythereissom
10、ethingwrong.TheproblemisthatnowtheFouriercoefficientshaveanimaginarycomponent,butCVXissearchingforarealx.Thesolutioniseasy,wejustneedtotellCVXtoconsideracomplexx:Listing8:Sparsesignalinthefrequencydomain.%SolveusingCVX.Psi=inv(fft(eye(n);cvxbeginvariablexp(n)complex;%WeneedtotellCVXthatxpiscomplex!m
11、inimize(norm(xp,1);subjecttoA*Psi*xp=y;cvxendFigure4showstheresult.Nowtherecoveryisexact.Wecanalsotrywithahighersparsitylevel.Thefollowingscriptcreateasignalbyaddingsixsinusoidswithrandomperiod,amplitudeandphases.Noticethattheperiodsarechosenfromthevector163264128256512.Figure5showstheresult.Onceaga
12、in,therecoveryisexact.Listing9:Signalmadeof6randomsinuoids.s=6;amp=rand(s,1);%amplitudesperiods=163264128256512;4tmp=randperm(length(periods);freq=(2*pi./round(periods(tmp(1:s);%frequenciesphases=2*pi*rnd(s,1);f=zeros(n,1);t=0:n-1;fork=1:s,f=f+amp(k)*cos(freq(k)*t+phases(k);endWenowreplacetheperiods
13、weareusingby183264128256512.Noticethattheonlydifferenceisthatnowthesmallestperiodis18insteadof16.Figure6showstheresult.Nowtheresultisnotexact.Thereasonforthisisthatnowthesignalisnotreallysparse,sinceoneoftheperiodsisnotanintegermultipleofthesignallength.AcknowledgmentsThankstoDr.MichaelWakinandBorhanSanandajiforhelpingmetosolvesomeoftheissuesIhadwiththecode.1Ifthesignalissparseinthetimedomain,=Identitymatrix,thatswhywedidntspecifyinsection1.Figure4:SuccessfullyrecoveryaftertellingCVXtouseacomple
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 甘肅省-2023年-社區(qū)工作者-上半年筆試真題卷
- 半導(dǎo)體行業(yè):不確定下的曙光亞太半導(dǎo)體騰飛
- 低溫倉儲(chǔ)冷鏈監(jiān)控系統(tǒng)考核試卷
- 智能交通系統(tǒng)與交通優(yōu)化考核試卷
- 建筑施工合同樣本:住宅改造工程
- 建筑施工臨時(shí)設(shè)施合同
- 電動(dòng)車租賃合同適用于電動(dòng)車租賃
- 碳鋼油罐租賃協(xié)議
- 蕪湖音樂教室租賃協(xié)議
- 建筑模板管理員招聘簡(jiǎn)章
- 醫(yī)療文書規(guī)范管理制度
- 山東第一醫(yī)科大學(xué)英語1(本)期末復(fù)習(xí)題
- 《相學(xué)集存》優(yōu)秀課件
- (完整版)新概念青少版1a1-10測(cè)試卷
- 國家開放大學(xué)《教育組織行為與管理案例》大作業(yè)參考答案
- 2018年上半年全市中小學(xué)部分學(xué)科德育優(yōu)質(zhì)課評(píng)選結(jié)果
- 低壓開關(guān)柜預(yù)防性試驗(yàn)報(bào)告
- 2023年江蘇蘇州工業(yè)園區(qū)管委會(huì)招聘筆試參考題庫附帶答案詳解
- DB33-T 1261-2021 全裝修住宅室內(nèi)裝修設(shè)計(jì)標(biāo)準(zhǔn) 附條文說明
- 優(yōu)化少先隊(duì)儀式教育的嘗試 論文
- 【知識(shí)解析】化學(xué)促進(jìn)科學(xué)技術(shù)的發(fā)展
評(píng)論
0/150
提交評(píng)論