zoukankan      html  css  js  c++  java
  • matlab计算样本熵

    计算14通道得脑电数据吗,将得出的样本熵插入Excel表格

    a = zeros(1,14);
    b = a';
      for i =1:14
          b(i) = SampEn(d1_1(i,1:3000),2,0.2*std(d1_1(i,1:3000)));
      end
    xlswrite('C:Users25626Desktop滤波后数据14样本熵样本熵.xlsx',b,'Sheet1','J');%数据写入A列
    

      调用的SampEn函数

    function SampEnVal = SampEn(data, m, r)
    % SampEn  计算时间序列data的样本熵
    % 输入:data是数据一维行向量
    %      m重构维数,一般选择1或2,优先选择2,一般不取m>2
    %      r 阈值大小,一般选择r=0.1~0.25*Std(data) 数据偏差
    % 输出:SampEnVal样本熵值大小
    
    data = data(:)';
    N = length(data);
    Nkx1 = 0;
    Nkx2 = 0;
    
    for k = N - m:-1:1
        x1(k, :) = data(k:k + m - 1);
        x2(k, :) = data(k:k + m);
    end
    
    for k = N - m:-1:1
        x1temprow = x1(k, :);
        x1temp    = ones(N - m, 1)*x1temprow;   
        dx1(k, :) = max(abs(x1temp - x1), [], 2)';   
        Nkx1 = Nkx1 + (sum(dx1(k, :) < r) - 1)/(N - m - 1);    
        x2temprow = x2(k, :);
        x2temp    = ones(N - m, 1)*x2temprow;
        dx2(k, :) = max(abs(x2temp - x2), [], 2)';
        Nkx2      = Nkx2 + (sum(dx2(k, :) < r) - 1)/(N - m - 1);
    end
    Bmx1 = Nkx1/(N - m);
    Bmx2 = Nkx2/(N - m);
    SampEnVal = -log(Bmx2/Bmx1);
    end
    

      

  • 相关阅读:
    拓扑排序
    最小费用最大流模板
    有上下界的网络流问题
    网络流模板
    LIS+LCS+LCIS
    【Vijos】1218 数字游戏
    【Vijos】1792 摆花
    【Vijos】1431 守望者的逃离
    【wikioi】1029 遍历问题
    背包模版
  • 原文地址:https://www.cnblogs.com/andrew-address/p/12725457.html
Copyright © 2011-2022 走看看