zoukankan      html  css  js  c++  java
  • sdtrend   remove annually cycle in matlab

    function [y,psave,ssave]=sdtrend(x,T,n,plfg,descriptor)

    %

    %   [y,psave,ssave]=sdtrend(x,T,n,plfg,descriptor)

    %

    % x = input series

    % T = period

    % n = order of polynomials to fit

    % plfg > 0 to plot series, residuals and seasonal trends

    % descriptor = string for plots

    if plfg

        �=figure;

        subplot(211);

        plot(x);

        title([descriptor,' with seasonal polys of degree : ',int2str(n)]);

        hold on;

    end

    colors=['y';'m';'c';'r';'g';'b'];

    ncols=6;

    colper=ncols;

    if T < ncols

        colper=T;

    end

    nx=length(x);

    resid0=zeros(size(x));

    ssave=[];

    psave=[];

    %legstr=descriptor;

    legstr=[];

    cnum=1;

    for j=1:T

        indexes=[j:T:nx];       % get the indexes starting at j and skipping by T

        xs=x(indexes);          % xs is x sampled at these indexes

        [pout,sout]=polyfit(indexes',xs,n);

        ssave=[ssave;sout];

        psave=[psave;pout];

        y=polyval(pout,indexes)'; % make it a column

        if plfg

            %figure(f1);

            hold on;

            plot(indexes',y,colors(cnum));

    %         legstr=[legstr;sprintf('s = %0.2d',j)];

            cnum=rem(cnum,colper)+1;

        end

        resid0(indexes)=x(indexes)-y;

        

    end

    y=resid0;

    if plfg

        % put on the legend for last plot

    %     legend(legstr,2);   % 2 puts legend in upper left corner

        hold off;

        

        %figure;

        subplot(212);

        plot(resid0);

        title([descriptor,'resids from sdtrend with polys of degree : ',int2str(n)]);

    end

  • 相关阅读:
    eclipse常用快捷键
    Sql server 问题诊断
    Oracle 表格大小分析
    VM虚拟机增加磁盘空间
    Linux搭建Nexus+Maven私人仓库
    Linux 下安装Git 版本管理工具 使用记录
    Jenkins 环境打建设 Linux
    Oracle 数据库用户表大小分析
    Windgb 其他常用命令
    Windbg 查内存占用
  • 原文地址:https://www.cnblogs.com/gisalameda/p/12840556.html
Copyright © 2011-2022 走看看