Matlab編程執行個體(1) 移動平均

來源:互聯網
上載者:User

標籤:

MATLAB數字訊號處理作業,把自己寫的程式發上來..歡迎交流~

QQ 五么九七九零六四 首先是任意點移動平均:主程式:mov_average_main.m (運行)函數:mov_average.m  (多點移動平均) /////////mov_average_main.m///////////%多點移動平均close all;clear all;numSample=500;    %採樣精度為100l=input(‘請輸入用於平滑的視窗大小"n"‘);if l>1 && l<50;    %對輸入變數控制else    error(‘您的輸入有誤!‘);end;t = linspace(0,pi/10,numSample); %建立向量A=10;%訊號幅值p=0;%訊號相位s = A*sin(100 * t+p);%產生正弦訊號n=randn(1,numSample);%用高斯隨機構造白色雜訊y=s+n;%疊加白色雜訊subplot(4,1,1);plot(t,s,‘r‘);title(‘原訊號‘);subplot(4,1,2);plot(t,n,‘b‘);title(‘白色雜訊訊號‘);subplot(4,1,3);plot(t,y,‘k‘);title(‘疊加白色雜訊後訊號‘);%調用移動平滑函數y=mov_average(numSample,l,y);%numSample為採樣精度,視窗大小為nsubplot(4,1,4);plot(t,y,‘k‘);title(‘n點移動平滑後‘); ///////mov_average.m /////////function y=mov_average(numSample,n,f)%mov_average是多點移動平滑函數%numSample為採用精度%n為用於平滑的視窗大小,其值應大於零且小於numSample%f為需要進行移動平滑處理的函數m=0;%m代表正在處理的點while m<numSample-n+1;%採樣點終止位置m=m+1;temp=0;%temp用於求n點函數值之和,此處將其清零for p=0:1:n-1; %p為視窗內變數的增量temp=temp+f(m+p) %n個點的數值總和end;f(m)=temp/n;%求均值end;y=f;%回代

 

Matlab編程執行個體(1) 移動平均

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.