如下所述,在 C++ 频域中具有所需的传递函数幅度,正确的相应最小相位是多少?一般来说,如果已知所需的幅度,特别是它的复数 IFFT 将返回一个完全实数的部分,那么如何在频域中导出正确的最小相位。
// PnCutoff.cpp : Pink noise above a cutoff.
#include <tchar.h>
#include <math.h>
#include <conio.h>
class PnAtFilter
{
double _fcHz;
public:
PnAtFilter(double fcHz) { _fcHz = fcHz; }
double Mag(double fHz)
{
if(fHz < _fcHz) return 1.0;
else return 1.0 / sqrt(fHz/_fcHz);
}
double Phase(double fHz)
{
return 0.0; // what is the the correct minimum phase in r?
}
};
int _tmain(int argc, _TCHAR* argv[])
{
PnAtFilter* pnf = new PnAtFilter(1000);
for(int fHz = 10; fHz <= 100000; fHz *= 10)
{
double mag = pnf->Mag(fHz);
double phase = pnf->Phase(fHz);
_cprintf_s("%d Mag=%f, Phase=%f\r\n", fHz, mag, phase);
}
_getch();
return 0;
}
/* output:
10 Mag=1.000000, Phase=0.000000
100 Mag=1.000000, Phase=0.000000
1000 Mag=1.000000, Phase=0.000000
10000 Mag=0.316228, Phase=0.000000
100000 Mag=0.100000, Phase=0.000000
*/