[求助]关于Hilbert变换
在matlab中的hilbert函数经常出现虚部误差过大,请问能否改进?回复:(suffer)[求助]关于Hilbert变换
Hilbert 变换在数学, Hilbert 变换 Hs (t) (并且写 s (t)) 真正的作用 s(t) 是积分式变换定义 n Hs (t) = s (t) = 1 - s ( )t- d n
就积分式而论作为避免稀有t =) 的Cauchy 主要价值(。
它可能并且被写与卷积操作员和: n s (t) = 1 t * s(t) n
s (t) 能被组建从 s(t) 由倍增其频率光谱 -i sgn( ), sgn 是的地方signum 作用和i 是虚数。这有转移所有的作用其消极频率由+90. 和所有正面频率根据 −90. 。注意Hilbert 变换并且原始的作用是两个同样可变物的作用。
Hilbert 变换有应用在信号处理。
回复:(van321)回复:(suffer)[求助]关于Hilbert变...
我这里有一个C语言写的Hilbert 变换你看看对你是否有帮助。来自于http://www.fysik.dtu.dk/~stoltze/tools/hilbert/hilbert.htm
/******************************************/
/* main.c
/******************************************/
#include <stdio.h>
#include <math.h>
#define N 500
#define sq(X) ((X)*(X))
int main()
{
int i;
double x;
double delta;
double kappa;
double y;
double xmin = -10.;
double xmax = 10.;
double cd = -1.;
double w = 2.;
double h = (xmax - xmin) / N;
for (i = 0; i < N; i++)
{
x = 2. * (xmin + i * h - cd) / w;
if (x < -1.)
delta = 0.;
else if (x < 1.)
delta = sqrt(1. - sq(x));
else
delta = 0.;
}
hilbert(n, delta, kappa);
for (i = 0; i < N; i++)
{
x = 2. * (xmin + i * h - cd) / w;
if (x < -1.)
y = x + sqrt(sq(x) - 1.);
else if (x < 1.)
y = x;
else
y = x - sqrt(sq(x) - 1.);
(void) printf("%.3f %.3f %.3f %.3f\n", xmin + i * h, delta, k
ppa, y);
}
return 0;
}
/******************************************/
/* hilbert.c
/******************************************/
void hilbert(int, double[], double[]);
/******************************************/
/* hilbert.c
/******************************************/
#include <stdio.h>
#include "hilbert.h"
#define PI 3.14159265
void hilbert(int n, double delta[], double kappa[])
{
double d1, d2, d3, d4;
int i1, i2;
for (i1 = 0; i1 < n; i1++)
{
kappa = 0.;
for (i2 = 1; i2 < n; i2++)
{
d1 = (i1+i2<N)? delta: 0.;
d2 = (i1-i2>=0)? delta: 0.;
d3 = (i1+i2+1<N)? delta: 0.;
d4 = (i1-i2-1>=0)? delta: 0.;
kappa -= 0.5 * (d1-d2) / i2 + 0.5 * (d3 - d4) / (i2
1);
}
kappa /= PI;
}
}
/***********************************************
/* 说明
/***********************************************
The Hilbert transform
This package performs a numerical Hilbert transform.
Download Compressed tar-file
or
hilbert.c and hilbert.h
Header file
The program must include the header file
#include "hilbert.h"
/***********************************************
/* 说明
kappa -= 0.5 * (d1-d2) / i2 + 0.5 * (d3 - d4) / (i2
1);
}
kappa /= PI;
}
}
/***********************************************
/* 说明
/***********************************************
The Hilbert transform
This package performs a numerical Hilbert transform.
Download Compressed tar-file
or
hilbert.c and hilbert.h
Header file
The program must include the header file
#include "hilbert.h"
and then call hilbert() to perform the transform.
Usage
If delta and kappa are arrays of n doubles, both arrays are allocated by the mai
program.
The input data are in delta and the call hilbert(n, delta, kappa) will return th
Hilbert transform of delta in kappa.
n and delta are not modified.
Compilation
Compile the package using a C-compiler.
If you use a makefile and this makefile looks like this
a.out: a.o b.o c.o
cc a.o b.o c.o
...
a. a.c d.h
cc -c a.c
...
and you use the package in a.c, change the makefile to look like this
a.out: a.o b.o c.o hilbert.o
cc a.o b.o c.o hilbert.o
...
a. a.c d.h hilbert.h
cc -c a.c
...
hilbert. hilbert.c hilbert.h
cc -c hilbert.c
Demo
main.c uses the package to perform a Hilbert transform of a semi-ellipsis.
Output from the program is a table.
First column: x
Second column: The semi-ellipsis
Third column: The Hilbert transform calculated by hilbert().
Fourth column: The analytical Hilbert transform of the semi-ellipsis. 改写过去也挺麻烦,不过谢谢啦,我试试看,不知道还有没有其他更方便点的方法? 我想用hilbert做包络检测<BR>那位做过
页:
[1]