From: kk KKsingh on
I am doing some thing wrong here ! I am only concern with the spectrum...

I have 750 samples
My sampling rate is 4.00e^-10;
f=-N/2:N/2-1
I am applying simple NDFT or Greg DFTGH ( As these lines are from greg code) on it Which is some thing like this....This is irregular signal not a regular one so taking real values in place of t instead of set of integer

x = x(:); % Format 'x' into a column vector
t = t(:); % Format 't' into a column vector
f = f(:); % Format 'f' into a column vector
dt = diff(t); % asymmetric "dt"
dts = 0.5*([dt; 0]+[0; dt]); % symmetric "dt"
meanx = sum(x.*dts)/sum(dts);
N=length(x);
df = diff(f); % asymmetric "df"
dfs = 0.5*([df; 0]+[0; df]); % symmetric "df"

W = exp(-2*pi*j * f*t');

XFT = W * (x.*dts);

freqaxis=1/dt/N*[f] (Assuming i have even number of samples)

plot(freqaxis,abs(XFT))

But I am getting weird output ! is some thing is wrong with the plotting..or freqaxias........i am saying weird because it not looking like spectrum not even close to FFT thing
From: kk KKsingh on
"kk KKsingh" <akikumar1983(a)gmail.com> wrote in message <i1fsla$3dh$1(a)fred.mathworks.com>...
> I am doing some thing wrong here ! I am only concern with the spectrum...
>
> I have 750 samples
> My sampling rate is 4.00e^-10;
> f=-N/2:N/2-1
> I am applying simple NDFT or Greg DFTGH ( As these lines are from greg code) on it Which is some thing like this....This is irregular signal not a regular one so taking real values in place of t instead of set of integer
>
> x = x(:); % Format 'x' into a column vector
> t = t(:); % Format 't' into a column vector
> f = f(:); % Format 'f' into a column vector
> dt = diff(t); % asymmetric "dt"
> dts = 0.5*([dt; 0]+[0; dt]); % symmetric "dt"
> meanx = sum(x.*dts)/sum(dts);
> N=length(x);
> df = diff(f); % asymmetric "df"
> dfs = 0.5*([df; 0]+[0; df]); % symmetric "df"
>
> W = exp(-2*pi*j * f*t');
>
> XFT = W * (x.*dts);
>
> freqaxis=1/dt/N*[f] (Assuming i have even number of samples)
>
> plot(freqaxis,abs(XFT))
>
> But I am getting weird output ! is some thing is wrong with the plotting..or freqaxias........i am saying weird because it not looking like spectrum not even close to FFT thing

Using this my X axis is same as in FFT, but in y axis amplitude is 10^-4 in NDFT and 10^14 in FFT ...Can any one tell me what is wrong
From: Greg Heath on
On Jul 12, 4:07 pm, "kk KKsingh" <akikumar1...(a)gmail.com> wrote:
> I am doing some thing wrong here ! I am only concern with the spectrum...
>
> I have 750 samples
> My sampling rate is 4.00e^-10;

N = 750
Fs = 4e-10 % THAT HAS GOT TO BE A MISTAKE!

df = Fs/N

> f=-N/2:N/2-1

f = df*(-N/2:N/2-1);


> I am applying simple NDFT or Greg DFTGH ( As these lines are from greg code) on it Which is some thing like this....This is irregular signal not a regular one so taking real values in place of t instead of set of integer
>
> x = x(:); % Format 'x' into a column vector
> t = t(:); % Format 't' into a column vector
> f = f(:); % Format 'f' into a column vector
> dt    = diff(t);                % asymmetric "dt"
> dts   = 0.5*([dt; 0]+[0; dt]);  % symmetric "dt"
> meanx = sum(x.*dts)/sum(dts);
> N=length(x);
> df   = diff(f);                % asymmetric "df"
> dfs  = 0.5*([df; 0]+[0; df]);  % symmetric "df"
>
> W    = exp(-2*pi*j * f*t');    
>
> XFT  = W * (x.*dts);
>
> freqaxis=1/dt/N*[f] (Assuming i have even number of samples)

In correct. dt is a vector (see above)

> plot(freqaxis,abs(XFT))

plot(f,abs(XFT))

> But I am getting weird output ! is some thing is wrong with the plotting...or freqaxias........i am saying weird because it not looking like spectrum not even close to FFT thing

Thats the result of incorrectly using 1/dt/N instead of (Fs/N).

Hope this helps.

Greg
From: Greg Heath on
On Jul 12, 6:34 pm, "kk KKsingh" <akikumar1...(a)gmail.com> wrote:
> "kk KKsingh" <akikumar1...(a)gmail.com> wrote in message <i1fsla$3d...(a)fred..mathworks.com>...
> > I am doing some thing wrong here ! I am only concern with the spectrum....
>
> > I have 750 samples
> > My sampling rate is 4.00e^-10;
> > f=-N/2:N/2-1
> > I am applying simple NDFT or Greg DFTGH ( As these lines are from greg code) on it Which is some thing like this....This is irregular signal not a regular one so taking real values in place of t instead of set of integer
>
> > x = x(:); % Format 'x' into a column vector
> > t = t(:); % Format 't' into a column vector
> > f = f(:); % Format 'f' into a column vector
> > dt    = diff(t);                % asymmetric "dt"
> > dts   = 0.5*([dt; 0]+[0; dt]);  % symmetric "dt"
> > meanx = sum(x.*dts)/sum(dts);
> > N=length(x);
> > df   = diff(f);                % asymmetric "df"
> > dfs  = 0.5*([df; 0]+[0; df]);  % symmetric "df"
>
> > W    = exp(-2*pi*j * f*t');    
>
> > XFT  = W * (x.*dts);
>
> > freqaxis=1/dt/N*[f] (Assuming i have even number of samples)
>
> > plot(freqaxis,abs(XFT))
>
> > But I am getting weird output ! is some thing is wrong with the plotting..or freqaxias........i am saying weird because it not looking like spectrum not even close to FFT thing
>
> Using this my X axis is same as in FFT, but in y axis amplitude is 10^-4 in NDFT and 10^14 in FFT ...Can any one tell me what is wrong-

DFT includes dt.

Therefore multiply XFFT by mean(dt) ~ 1/Fs = 0.25 * 10^10.

Hope this helps.

Greg