- #1
btb4198
- 572
- 10
ok I have been troubleshooting this code left and right... but I am still not getting what Mat lab is getting...
can someone please look at this for me ?
can someone please look at this for me ?
Code:
private float Fs;
private int N;
private Complex [] F;
private int R;
private Complex[] x;
public DSPclass(float[] DSP1,int f1)
{
N = DSP1.Length;
R = DSP1.Length;
F = new Complex[N];
Fs = (float)f1;
x = new Complex[DSP1.Length];
for (int v = 0; v < N; v++)
{
x[v] = DSP1[v];
}
}
public void FFT1()
{
F = FFT(x);
}
public Complex[] FFT(Complex[] x)
{
int N2 = x.Length;
Complex[] X = new Complex[N2];
if (N2 == 1)
{
return x;
}
Complex[] odd = new Complex[N2 / 2];
Complex[] even = new Complex[N2 / 2];
Complex[] Y_Odd = new Complex[N2 / 2];
Complex[] Y_Even = new Complex[N2 / 2];
for (int t = 0; t < N2 / 2; t++)
{
even[t] = x[t * 2];
odd[t] = x[(t * 2) + 1];
}
Y_Even = FFT(even);
Y_Odd = FFT(odd);
Complex temp4;
for (int k = 0; k < (N2 / 2); k++)
{
temp4 = Complex1(k, N);
X[k] = Y_Even[k] + (Y_Odd[k] * temp4);
X[k + (N2 / 2)] = Y_Even[k] - (Y_Odd[k] * temp4);
}
return X;
}