MATLAB Programming Example (1) Moving average

Source: Internet
Author: User

MATLAB digital signal processing operations, write their own program to send up. Welcome to Exchange ~

QQ Wu 979064   First is any point moving average: Main program: MOV_AVERAGE_MAIN.M (Run) function: MOV_AVERAGE.M   (multi-point moving average)  /////////mov_average_ main.m///////////% Multi-point moving average close all;clear all;numsample=500;    % sampling accuracy is 100l=input (' Please enter the window size for smoothing ' n '); if l>1 && l<50;    % control of the input variable else    error (' Your input is wrong! '); end;t = Linspace (0,pi/10,numsample); % Create vector a=10;% signal amplitude p=0;% signal phase s = A*sin (t+p),% generates sinusoidal signal N=randn (1,numsample),% with Gaussian random structure white noise y=s+n;% overlay white noise subplot (4,1,1); Plot (t,s, ' R '), title (' Original Signal '), subplot (4,1,2);p lot (t,n, ' B '), title (' White Noise signal '), subplot (4,1,3);p lot (t,y, ' K '), title (' Add white noise after signal '),% call Move smoothing function Y=mov_average (numsample,l,y),%numsample for sampling precision, window size nsubplot (4,1,4);p lot (t,y, ' K '); N-point movement smoothed after '); &NBSP;///////MOV_AVERAGE.M/////////function y=mov_average (numsample,n,f)%mov_average is a multi-point move smoothing function% The numsample is to use the precision%n for the window size that is used for smoothing, whose value should be greater than 0 and less than numsample%f for the function that needs to be moved smooth m=0;%m represents the point while the m<numsample-n+1;% sample point is being processed m=m +1;temp=0;%temp is used to calculate the sum of the value of the N-point function, where it is cleared 0 for p=0:1:n-1; %p is the sum of the values of the increment temp=temp+f (m+p)%n points of the variables in the window end;f (m) =temp/n;% mean value end;y=f;% back generation

MATLAB Programming Example (1) Moving average

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.