资源简介
使用db4小波,对离散信号进行分解重构,代码数据都有。
代码片段和文件信息
#define N0 1024*2
#include “stdio.h“
#include “stdlib.h“
#include “math.h“
#include “string.h“
#include “tool.h“
void db4(double *h0double *h1double *g0double *g1);
void conv(double *aint len_adouble *bint len_bdouble *result);
void wkeep(double *aint len_aint lendouble *result);
void dyaddown(double *aint len_adouble *result);
void dyadup(double *aint len_adouble *result);
void vectoradd(double *adouble *bint len_adouble *result);
void vectordetract(double *adouble *bint len_adouble *result);
void main()
{
int LEN_F=8LEN_S;
double h0[8]h1[8]g0[8]g1[8];
double *orign_y*recon_y*diff_y;
//float fk0[N0];
double *decom_low *decom_hig;
double *decom_low_down *decom_hig_down;
double *recon_low_up *recon_hig_up;
double *recon_low *recon_hig;
double *recon_low_better*recon_hig_better;
FILE *fp;
int iLEN_K;
char *FileName=“Data.txt“;
float file_y[N0];
//输入信号fk0长度为N
fp=fopen(“wdata.dat““rt“);
fscanf(fp“%d“&LEN_S);
orign_y = (double *) calloc( LEN_Ssizeof(double));
recon_y = (double *) calloc( LEN_Ssizeof(double));
diff_y = (double *) calloc( LEN_Ssizeof(double));
decom_low= (double *) calloc(LEN_S+LEN_F-1sizeof(double));
decom_hig= (double *) calloc(LEN_S+LEN_F-1sizeof(double));
decom_low_down= (double *) calloc( (LEN_S+LEN_F-1)/2sizeof(double));
decom_hig_down= (double *) calloc( (LEN_S+LEN_F-1)/2sizeof(double));
LEN_K=(LEN_S+LEN_F-1)/2*2+1;
recon_low_up= (double *) calloc( LEN_Ksizeof(double));
recon_hig_up= (double *) calloc( LEN_Ksizeof(double));
recon_low= (double *) calloc( LEN_K+LEN_F-1sizeof(double));
recon_hig= (double *) calloc( LEN_K+LEN_F-1sizeof(double));
recon_low_better= (double *) calloc( LEN_Ssizeof(double));
recon_hig_better= (double *) calloc( LEN_Ssizeof(double));
for(i=0;i fscanf(fp“%f“&file_y[i]);
orign_y[i]=file_y[i];
}
fclose(fp);
//构造滤波器组(分解的高通低通,重构的高通低通)
db4(h0h1g0g1);
fp=fopen(FileName“w“);fclose(fp);
Vector2File(FileName“\n\n滤波器系数\n“LEN_F“\th0=%10f“h0“\th1=%10f“h1“\tg0=%10f“g0“\tg1=%10f\n“g1““);
//对信号进行小波分解
/*
decom_low=conv(yLOW_DECOMPOSE); %卷积
decom_hig=conv(yHIGH_DECOMPOSE);
decom_low_down=dyaddown(decom_low); %抽取得低频细节
decom_hig_down=dyaddown(decom_hig); %信号高频细节
decom_low
decom_hig
decom_low_down
decom_hig_down
*/
conv(h0LEN_Forign_yLEN_Sdecom_low);
conv(h1LEN_Forign_yLEN_Sdecom_hig);
dyaddown(decom_lowLEN_S+LEN_F-1decom_low_down);
dyaddown(decom_higLEN_S+LEN_F-1decom_hig_down);
Vector2File(FileName“\n\n分解的高低频系数\n“LEN_S+LEN_F-1“\tdecom_low=%10f“decom_low“\tdecom_hig=%10f\n“decom_hig““);
Vector2File(FileName“\n\n分解的高低频系数(二抽取)\n“(LEN_S+LEN_F-1)/2“\tdecom_low_down=%10f“decom_low_down“\tdecom_hig_down=%10f\n“decom_hig_down““);
//对信号进行小波重构
/*
recon_low_up=dyadup(decom_low_down); %0差值
recon_hig_up=dyadup(decom_hig_down);
recon_low=conv(LOW_CONSTRUCTrecon_low_up);
recon_hig=conv(HIGH_CONSTRUCTrecon_hig_up);
recon_
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 154 2005-03-11 10:43 1DSignal_DecomRecon_Bywavelet[xtulbd050311]\readme.txt
文件 6167 2005-03-03 20:33 1DSignal_DecomRecon_Bywavelet[xtulbd050311]\一维信号的小波分解和重构的C代码\Mallat.c
文件 3458 2005-03-02 20:25 1DSignal_DecomRecon_Bywavelet[xtulbd050311]\一维信号的小波分解和重构的C代码\Mallat.dsp
文件 58368 2005-03-11 10:44 1DSignal_DecomRecon_Bywavelet[xtulbd050311]\一维信号的小波分解和重构的C代码\Mallat.ncb
文件 1163 2005-03-03 20:33 1DSignal_DecomRecon_Bywavelet[xtulbd050311]\一维信号的小波分解和重构的C代码\Mallat.plg
文件 537 2005-02-28 21:42 1DSignal_DecomRecon_Bywavelet[xtulbd050311]\一维信号的小波分解和重构的C代码\Mallat.dsw
文件 244 2005-03-01 11:10 1DSignal_DecomRecon_Bywavelet[xtulbd050311]\一维信号的小波分解和重构的C代码\wdata.dat
文件 1822 2005-03-03 08:56 1DSignal_DecomRecon_Bywavelet[xtulbd050311]\一维信号的小波分解和重构的C代码\tool.h
文件 9538 2005-03-11 10:36 1DSignal_DecomRecon_Bywavelet[xtulbd050311]\一维信号的小波分解和重构的C代码\Data.txt
文件 48640 2005-03-11 10:44 1DSignal_DecomRecon_Bywavelet[xtulbd050311]\一维信号的小波分解和重构的C代码\Mallat.opt
目录 0 2005-03-11 10:44 1DSignal_DecomRecon_Bywavelet[xtulbd050311]\一维信号的小波分解和重构的C代码\Debug
目录 0 2005-03-11 10:44 1DSignal_DecomRecon_Bywavelet[xtulbd050311]\一维信号的小波分解和重构的C代码
目录 0 2005-03-11 10:45 1DSignal_DecomRecon_Bywavelet[xtulbd050311]
-rw-r--r-- 227 2011-08-12 15:27 readme_verysource.com.txt
----------- --------- ---------- ----- ----
130318 14
- 上一篇:世界国家边界范围shp
- 下一篇:新时达二代一体机服务器万能程序
评论
共有 条评论