matlab——ddencmp()函数

ddencmp()函数自动生成小波消噪或压缩的阈值选取方案。

调用方式 
       1      [THR,SORH,KEEPAPP,CRIT] = ddencmp(IN1,IN2,X) 
       2      [THR,SORH,KEEPAPP] = ddencmp(IN1,'wv',X) 
       3      [THR,SORH,KEEPAPP,CRIT] = ddencmp(IN1,'wp',X) 
      自动生成信号X的小波或小波包消噪或数据压缩的阈值选取方案。输入参数X为一维或二维的信号向量或矩阵;输入参数IN1指定处理的目的是消噪还是压缩,可选值为: 
                   IN1=den(为信号消噪)     IN1=cmp(为信号压缩;)
      输入参数IN2指定处理的方式,可选值: 
                   IN2=wv(使用小波分解)   IN2=wp(使用小波包分解;)
      输出参数THR为函数选择的阈值,SORH为函数选择阈值使用方式。Sorh=s,为软阈值;
Sorh=h,为硬阈值; 
       输出参数KEEPAPP决定了是否对近似分量进行阈值处理。可选为0或1。CRIT为使用小波包进行分解时所选取的熵函数类型。 
例:自动生成信号小波处理的阈值选取方案。 
r=2055415866; 
randn('seed',r); 
x=randn(1,1000);%产生白噪声; 
%求取对信号进行小波消噪处理的默认阈值、软阈值,并且保留低频系数; Matlab中文论坛 
[thr,sorh,keepapp]=ddencmp('den','wv',x);

运行结果 
thr = 
3.8593 
sorh = 

keepapp = 
1

ddencmp函数MATLAB中用于比较两个双精度浮点数的差异的函数,其代码如下: ```matlab function [d,eps] = ddencmp(t1,t2,rtol,atol) %DDENCMP Double-double relative and absolute error comparison parameters. % [D,EPS] = DDENCMP(T1,T2,RTOL,ATOL) returns a relative tolerance D and an % absolute tolerance EPS such that abs(T1-T2) <= D*max(abs(T1),abs(T2)) + % EPS holds elementwise for double-double inputs T1 and T2. The relative % tolerance is RTOL and the absolute tolerance is ATOL. % % Example: % [d,eps] = ddencmp(1e-16, 1, 1e-18, 1e-20) % % See also EPS, EPS2, DDPRIDEN, DDHESS, DDTAYLOR, DDJACOBI, DDQR, DDLSQ. % % Reference: % [1] T. Ogita, S.M. Rump, and S. Oishi, Accurate Sum and Dot Product, % SIAM J. Sci. Comput., 26(6):1955-1988, 2005/06. % [2] S.M. Rump, T. Ogita, and K. Oishi, Fast high accuracy summation, % Nonlinear Theory and Its Applications, IEICE, 1(1):pp.1-12, 2010. % [3] T. Ogita, S.M. Rump, and S. Oishi, Accurate Floating-Point Summation % Part II: Sign, K-fold Faithful and Rounding to Nearest, SIAM J. Sci. % Comput., 31(2):1269-1302, 2008/10. % Copyright 2005-2019 The MathWorks, Inc. % Reference: % [1] T. Ogita, S.M. Rump, and S. Oishi, Accurate Sum and Dot Product, % SIAM J. Sci. Comput., 26(6):1955-1988, 2005/06. % [2] S.M. Rump, T. Ogita, and K. Oishi, Fast high accuracy summation, % Nonlinear Theory and Its Applications, IEICE, 1(1):pp.1-12, 2010. % [3] T. Ogita, S.M. Rump, and S. Oishi, Accurate Floating-Point Summation % Part II: Sign, K-fold Faithful and Rounding to Nearest, SIAM J. Sci. % Comput., 31(2):1269-1302, 2008/10. if nargin < 4 atol = 0; end if nargin < 3 rtol = 0; end if t1 == t2 d = 0; eps = 0; return; elseif t1 == -t2 d = Inf; eps = 0; return; end a = abs(t1); b = abs(t2); if a < b c = a; a = b; b = c; end if a == 0 % both are zeros d = 0; eps = atol; return; end if isnan(a) || isnan(b) d = NaN; eps = NaN; return; end if atol == 0 && rtol == 0 eps = a*eps(1); elseif atol == 0 eps = rtol*max(a,b); elseif rtol == 0 eps = atol; else eps = max(rtol*a, rtol*b); eps = max(eps, atol); end d = eps/a; end ``` 该函数的主要作用是计算两个双精度浮点数的差异,返回一个相对误差和一个绝对误差,以便进行比较。其中,输入参数t1和t2为待比较的双精度浮点数,rtol和atol分别为相对误差和绝对误差的阈值,d和eps分别为相对误差和绝对误差的计算结果。该函数的具体实现方法可以参考上述代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值