MATLAB Fundamentals>>>Smoothing Data with Moving Average

MATLAB Fundamentals>Common Data Analysis Techniques>Smoothing Data> (2/5) Smoothing Data with Moving Average


例1:

Smoothing method:Moving mean

Moving window:Centered 2

代码2:

% Smooth input data
ySm = smoothdata(y,"movmean",2,"SamplePoints",x);

% Display results
figure
plot(x,y,"SeriesIndex",6,"DisplayName","Input data")
hold on
plot(x,ySm,"SeriesIndex",1,"LineWidth",1.5, ...
    "DisplayName","Smoothed data")
hold off
legend
xlabel("x")

例2:

Smoothing method:Moving mean

Smoothing factor:0.25

代码2:

% Smooth input data
ySm = smoothdata(y,"movmean","SmoothingFactor",0.25,"SamplePoints",x);

% Display results
figure
plot(x,y,"SeriesIndex",6,"DisplayName","Input data")
hold on
plot(x,ySm,"SeriesIndex",1,"LineWidth",1.5, ...
    "DisplayName","Smoothed data")
hold off
legend
xlabel("x")

例3:

Smoothing method:Moving median

Moving window:Centered 2

代码3:

% Smooth input data
ySm = smoothdata(y,"movmedian",2,"SamplePoints",x);

% Display results
figure
plot(x,y,"SeriesIndex",6,"DisplayName","Input data")
hold on
plot(x,ySm,"SeriesIndex",1,"LineWidth",1.5, ...
    "DisplayName","Smoothed data")
hold off
legend
xlabel("x")

例4:

Smoothing method:Gaussian filter

Moving window:Centered 2

代码4:

% Smooth input data
ySm = smoothdata(y,"gaussian",2,"SamplePoints",x);

% Display results
figure
plot(x,y,"SeriesIndex",6,"DisplayName","Input data")
hold on
plot(x,ySm,"SeriesIndex",1,"LineWidth",1.5, ...
    "DisplayName","Smoothed data")
hold off
legend
xlabel("x")

例5:

Smoothing method:Local linear regression(lowess)

Moving window:Centered 2

代码5:

% Smooth input data
ySm = smoothdata(y,"lowess",2,"SamplePoints",x);

% Display results
figure
plot(x,y,"SeriesIndex",6,"DisplayName","Input data")
hold on
plot(x,ySm,"SeriesIndex",1,"LineWidth",1.5, ...
    "DisplayName","Smoothed data")
hold off
legend
xlabel("x")

例6:

Smoothing method:Local quadratic regression(loess)

Moving window:Centered 2

代码6:

% Smooth input data
ySm = smoothdata(y,"loess",2,"SamplePoints",x);

% Display results
figure
plot(x,y,"SeriesIndex",6,"DisplayName","Input data")
hold on
plot(x,ySm,"SeriesIndex",1,"LineWidth",1.5, ...
    "DisplayName","Smoothed data")
hold off
legend
xlabel("x")

例7:

Smoothing method:Robust Lowess

Moving window:Centered 2

代码7:

% Smooth input data
ySm = smoothdata(y,"rlowess",2,"SamplePoints",x);

% Display results
figure
plot(x,y,"SeriesIndex",6,"DisplayName","Input data")
hold on
plot(x,ySm,"SeriesIndex",1,"LineWidth",1.5, ...
    "DisplayName","Smoothed data")
hold off
legend
xlabel("x")

例8:

Smoothing method:Roubst Loess

Moving window:Centered 2

代码8:

% Smooth input data
ySm = smoothdata(y,"rloess",2,"SamplePoints",x);

% Display results
figure
plot(x,y,"SeriesIndex",6,"DisplayName","Input data")
hold on
plot(x,ySm,"SeriesIndex",1,"LineWidth",1.5, ...
    "DisplayName","Smoothed data")
hold off
legend
xlabel("x")

例9:

Smoothing method:Savitzky-Golay polynomial filter

polynomial degree:2

Moving window:Centered 2

代码9:

% Smooth input data
ySm = smoothdata(y,"sgolay",2,"SamplePoints",x);

% Display results
figure
plot(x,y,"SeriesIndex",6,"DisplayName","Input data")
hold on
plot(x,ySm,"SeriesIndex",1,"LineWidth",1.5, ...
    "DisplayName","Smoothed data")
hold off
legend
xlabel("x")

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2024-01-23 06:08:03       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-23 06:08:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-23 06:08:03       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-23 06:08:03       20 阅读

热门阅读

  1. Mongodb 控制查询返回字段

    2024-01-23 06:08:03       34 阅读
  2. RPC教程 4.超时处理机制

    2024-01-23 06:08:03       27 阅读
  3. Redis通过dump.rdb恢复数据

    2024-01-23 06:08:03       34 阅读
  4. MySQL数据备份

    2024-01-23 06:08:03       32 阅读
  5. 使用docker以容器方式安装redis

    2024-01-23 06:08:03       30 阅读
  6. 【PostgreSQL】创建枚举类型和修改枚举值

    2024-01-23 06:08:03       35 阅读
  7. 使用github作为docker镜像存储仓库

    2024-01-23 06:08:03       34 阅读
  8. 音频开发之ALSA框架

    2024-01-23 06:08:03       35 阅读