版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(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ǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 臨床軟組織血管瘤影像診斷
- 新解讀《TNAIC 001-2018物聯(lián)網(wǎng)無線火災(zāi)自動(dòng)報(bào)警系統(tǒng)技術(shù)規(guī)范 》
- 新解讀《GB 51258-2017玻璃纖維工廠設(shè)計(jì)標(biāo)準(zhǔn) 》
- “防弊”之制-兩宋的政治和軍事課件-2025屆+高三統(tǒng)編版(2019)必修中外歷史綱要上一輪復(fù)習(xí)
- 24.4 弧長和扇形面積 人教版數(shù)學(xué)九年級(jí)上冊堂堂練(含答案)
- 紐貝佳加愛羊奶粉產(chǎn)品知識(shí)測試
- 2024-2025學(xué)年浙江省溫州市樂清市三年級(jí)(上)第一次月考數(shù)學(xué)試卷
- 股權(quán)融資對企業(yè)社會(huì)責(zé)任戰(zhàn)略的實(shí)施提升影響研究
- 江蘇省南京市南師附中江寧分校2023-2024學(xué)年中考適應(yīng)性考試數(shù)學(xué)試題含解析
- 有機(jī)礦物質(zhì)發(fā)酵食品科技行業(yè)的消費(fèi)心理分析
- 賈否動(dòng)畫概論第三版優(yōu)質(zhì)課件
- 彌漫性間質(zhì)性肺病診斷思路-董文
- 含山昱潔環(huán)??萍加邢薰竞浇?jīng)濟(jì)開發(fā)區(qū)樹脂砂綜合處置中心建設(shè)項(xiàng)目環(huán)境影響報(bào)告表
- 肩周炎肩關(guān)節(jié)周圍炎治療與康復(fù)
- 明視視光中心創(chuàng)業(yè)計(jì)劃書
- 拼音詞語總表1
- 基因毒性雜質(zhì)全面信息資料
- GB/T 20981-2007面包
- GB/T 1914-2017化學(xué)分析濾紙
- GB/T 14100-1993燃?xì)廨啓C(jī)驗(yàn)收試驗(yàn)
- 項(xiàng)目一-發(fā)售車票課件
評論
0/150
提交評論