using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using static System.Net.WebRequestMethods;
namespace Split_Radix_FFT
{
public partial class Split_Radix_FFTForm : Form
{
public Split_Radix_FFTForm()
{
InitializeComponent();
}
/************************************
* x(i) = Qⁱ, i= 0,.....n-1
* DFT X(k) = (1-Qⁿ)/(1-QWᵏ) k= 0,......n-1, W = e^(-j2π/n)
* Q = 0.9 + j 0.3
* n=32,
************************************/
private void btTransform_Click(object sender, EventArgs e)
{
int i, j, n;
double a1, a2, c, c1, c2, d1, d2, q1, q2, w, w1, w2;
double[] x = new double[64];
double[] y = new double[64];
double[] a = new double[64];
double[] b = new double[64];
n = 64;
a1 = 0.9;
a2 = 0.3;
x[0] = 1.0;
y[0] = 0.0;
for (i = 1; i < n; i++)
{
x[i] = a1 * x[i - 1] - a2 * y[i - 1];
y[i] = a2 * x[i - 1] + a1 * y[i - 1];
}
rbPointData.AppendText("\n Complex Input Sequence \n");
for (i = 0; i < n / 2; i++)
{
for (j = 0; j < 2; j++)
rbPointData.AppendText(x[2 * i + j].ToString("f6") + " \t"+ "J "+ y[2 * i + j].ToString("f6") + "\t");
rbPointData.AppendText("\n");
}
for(i=0; i < n ;i++)
{
this.chart1.Series[0].Points.AddXY(x[i], y[i]);
}
q1 = x[n - 1];
q2 = y[n - 1];
for (i = 0; i < n; i++)
{
w = 6.28318530718 / n * i;
w1 = Math.Cos(w);
w2 = -Math.Sin(w);
c1 = 1.0 - a1 * w1 + a2 * w2;
c2 = a1 * w2 + a2 * w1;
c = c1 * c1 + c2 * c2;
d1 = 1.0 - a1 * q1 + a2 * q2;
d2 = a1 * q2 + a2 * q1;
a[i] = (c1 * d1 + c2 * d2) / c;
b[i] = (c2 * d1 - c1 * d2) / c;
} rbTransformData.AppendText("\n Theoretical Discrete Fourier Transform \n");
for (i = 0; i < n / 2; i++)
{
for (j = 0; j < 2; j++)
rbTransformData.AppendText(a[2 * i + j].ToString("F6") + " \t"+"J " + b[2 * i + j].ToString("f6") + "\t");
rbTransformData.AppendText("\n");
}
for (i = 0; i < n; i++)
{
this.chart2.Series[0].Points.AddXY(a[i], b[i]);
}
srfft(x, y, n);
rbPointData.AppendText("\n Split Radix Fast Fourier Transform:\n");
for (i = 0; i < n / 2; i++)
{
for (j = 0; j < 2; j++)
rbPointData.AppendText(x[2 * i + j].ToString("f6") + " \t" + "J " + y[2 * i + j].ToString("f6") + "\t");
rbPointData.AppendText("\n");
}
for (i = 0; i < n; i++)
{
this.chart1.Series[1].Points.AddXY(x[i], y[i]);
}
isrfft(x, y, n);
rbTransformData.AppendText("\n Inverse Radix4 Fast Fourier Transform\n");
for (i = 0; i < n / 2; i++)
{
for (j = 0; j < 2; j++)
rbTransformData.AppendText(x[2 * i + j].ToString("f6") + " \t" + "J " + y[2 * i + j].ToString("f6") + "\t");
rbTransformData.AppendText("\n");
}
for (i = 0; i < n; i++)
{
this.chart2.Series[1].Points.AddXY(x[i], y[i]);
}
}
}
}
分裂基快速傅里叶变换 反变换, Split Radix Fast Fourier Transform
最新推荐文章于 2023-11-15 11:44:25 发布