Reply by Ron N. November 14, 20072007-11-14
On Nov 14, 5:47 am, Richard Owlett <rowl...@atlascomm.net> wrote:
> Richard Owlett wrote: > > Tim Wescott wrote: > > >> On Tue, 13 Nov 2007 17:32:26 -0600, Richard Owlett wrote: > > >>> In another thread it was suggested I use Scilab's smooth() function > >>> to increase my effective sample rate (sample code was given). > > >>> I applied the code to my problem and got the desired effect. > > >>> I performed an FFT on the smoothed data and did not get a spectrum of > >>> the expected character. I could couldn't find a programming error. > > [snip majority of Scilab test code] > > > > > > >>> // plot both with normalized (0 -> 1.0) frequency axis > >>> subplot(223) > >>> plot2d([0:sa-1]/sa, a); // FFT of 'jaggy' signal > >>> // major peaks at .03, .32, .67, .97 > > >>> subplot(224) > >>> plot2d([0:sb-1]/sb, b, style = 2); // FFT of smoothed signal > >>> // major peaks at .0017, .017, .98, .998 > > >>> I expected the narrower peaks. > >>> BUT, shouldn't they be at the same normalized frequency? > > >> No, they should be at the same un-normalized frequency. You're doing > >> DFTs > >> on segments of data that are the same duration, so one cycle/segment > >> has a > >> frequency of 1/(segment length) no matter how fine you divide your > >> samples > >> down. > > > DUH ;/ > > Woke up about 3AM realizing where I went wrong. > > Thanks > > Now that my plot no longer confuses pints to bushels, I have a question. > > Given a signal sampled at two different rates (eg 4X and 64X Nyquist) > for the same length of time, what is the effect on the FFT performed on > the 2 sets of data? > > The only thing I could prove is the amplitude of the peaks in the > frequency would be proportional to the sample rate.
If the signal is perfectly bandlimited below 2X your assumed Nyquist, then all the information content is only 2X Nyquist. More samples only produce redundant data (interpolations). If your signal isn't perfect in bandlimitation (e.g. it's not infinite in length, etc.) then the differences between the higher sample rate might display the leakage of your low pass filter, differences in sampling jitter, and such. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M
Reply by Richard Owlett November 14, 20072007-11-14
Richard Owlett wrote:
> Tim Wescott wrote: > >> On Tue, 13 Nov 2007 17:32:26 -0600, Richard Owlett wrote: >> >> >>> In another thread it was suggested I use Scilab's smooth() function >>> to increase my effective sample rate (sample code was given). >>> >>> I applied the code to my problem and got the desired effect. >>> >>> I performed an FFT on the smoothed data and did not get a spectrum of >>> the expected character. I could couldn't find a programming error. >>>
[snip majority of Scilab test code]
>>> >>> // plot both with normalized (0 -> 1.0) frequency axis >>> subplot(223) >>> plot2d([0:sa-1]/sa, a); // FFT of 'jaggy' signal >>> // major peaks at .03, .32, .67, .97 >>> >>> subplot(224) >>> plot2d([0:sb-1]/sb, b, style = 2); // FFT of smoothed signal >>> // major peaks at .0017, .017, .98, .998 >>> >>> I expected the narrower peaks. >>> BUT, shouldn't they be at the same normalized frequency? >> >> >> No, they should be at the same un-normalized frequency. You're doing >> DFTs >> on segments of data that are the same duration, so one cycle/segment >> has a >> frequency of 1/(segment length) no matter how fine you divide your >> samples >> down. >> > > DUH ;/ > Woke up about 3AM realizing where I went wrong. > Thanks
Now that my plot no longer confuses pints to bushels, I have a question. Given a signal sampled at two different rates (eg 4X and 64X Nyquist) for the same length of time, what is the effect on the FFT performed on the 2 sets of data? The only thing I could prove is the amplitude of the peaks in the frequency would be proportional to the sample rate.
Reply by Richard Owlett November 14, 20072007-11-14
Tim Wescott wrote:
> On Tue, 13 Nov 2007 17:32:26 -0600, Richard Owlett wrote: > > >>In another thread it was suggested I use Scilab's smooth() function to >>increase my effective sample rate (sample code was given). >> >>I applied the code to my problem and got the desired effect. >> >>I performed an FFT on the smoothed data and did not get a spectrum of >>the expected character. I could couldn't find a programming error. >> >>I've created the test case below. >> >> >>ptd = 0:30; ptd = [ptd; sin(ptd).*sin(1.1*ptd)]; // make 'signal' to smooth >>pt = smooth(ptd, 0.05); // smooth it with splines >>clf; // clear the current figure >> >>// plot both with same time axis >>subplot(221) >>plot2d(ptd(1,:), ptd(2,:)); // plot the 'jaggy' signal >>subplot(222) >>plot2d(pt(1,:), pt(2,:), style = 2); // plot the smoothed signal >> >>siz_raw1 = size(ptd,2) >>w1=window('hm',siz_raw1); >>a=abs(fft(ptd(2,:).*w1)); // FFT of windowed data >> >>siz_raw2 = size(pt,2) >>w2=window('hm',siz_raw2); >>b=abs(fft(pt(2,:).*w2)); >> >>sa=size(a,2); >>sb=size(b,2); >> >>// plot both with normalized (0 -> 1.0) frequency axis >>subplot(223) >>plot2d([0:sa-1]/sa, a); // FFT of 'jaggy' signal >>// major peaks at .03, .32, .67, .97 >> >>subplot(224) >>plot2d([0:sb-1]/sb, b, style = 2); // FFT of smoothed signal >>// major peaks at .0017, .017, .98, .998 >> >>I expected the narrower peaks. >>BUT, shouldn't they be at the same normalized frequency? > > > No, they should be at the same un-normalized frequency. You're doing DFTs > on segments of data that are the same duration, so one cycle/segment has a > frequency of 1/(segment length) no matter how fine you divide your samples > down. >
DUH ;/ Woke up about 3AM realizing where I went wrong. Thanks
Reply by Tim Wescott November 14, 20072007-11-14
On Tue, 13 Nov 2007 17:32:26 -0600, Richard Owlett wrote:

> In another thread it was suggested I use Scilab's smooth() function to > increase my effective sample rate (sample code was given). > > I applied the code to my problem and got the desired effect. > > I performed an FFT on the smoothed data and did not get a spectrum of > the expected character. I could couldn't find a programming error. > > I've created the test case below. > > > ptd = 0:30; ptd = [ptd; sin(ptd).*sin(1.1*ptd)]; // make 'signal' to smooth > pt = smooth(ptd, 0.05); // smooth it with splines > clf; // clear the current figure > > // plot both with same time axis > subplot(221) > plot2d(ptd(1,:), ptd(2,:)); // plot the 'jaggy' signal > subplot(222) > plot2d(pt(1,:), pt(2,:), style = 2); // plot the smoothed signal > > siz_raw1 = size(ptd,2) > w1=window('hm',siz_raw1); > a=abs(fft(ptd(2,:).*w1)); // FFT of windowed data > > siz_raw2 = size(pt,2) > w2=window('hm',siz_raw2); > b=abs(fft(pt(2,:).*w2)); > > sa=size(a,2); > sb=size(b,2); > > // plot both with normalized (0 -> 1.0) frequency axis > subplot(223) > plot2d([0:sa-1]/sa, a); // FFT of 'jaggy' signal > // major peaks at .03, .32, .67, .97 > > subplot(224) > plot2d([0:sb-1]/sb, b, style = 2); // FFT of smoothed signal > // major peaks at .0017, .017, .98, .998 > > I expected the narrower peaks. > BUT, shouldn't they be at the same normalized frequency?
No, they should be at the same un-normalized frequency. You're doing DFTs on segments of data that are the same duration, so one cycle/segment has a frequency of 1/(segment length) no matter how fine you divide your samples down. -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
Reply by Richard Owlett November 13, 20072007-11-13
In another thread it was suggested I use Scilab's smooth() function to 
increase my effective sample rate (sample code was given).

I applied the code to my problem and got the desired effect.

I performed an FFT on the smoothed data and did not get a spectrum of 
the expected character. I could couldn't find a programming error.

I've created the test case below.


ptd = 0:30; ptd = [ptd; sin(ptd).*sin(1.1*ptd)]; // make 'signal' to smooth
pt = smooth(ptd, 0.05);                 // smooth it with splines
clf;                                    // clear the current figure

// plot both with same time axis
subplot(221)
plot2d(ptd(1,:), ptd(2,:));             // plot the 'jaggy' signal
subplot(222)
plot2d(pt(1,:), pt(2,:), style = 2);    // plot the smoothed signal

siz_raw1 = size(ptd,2)
w1=window('hm',siz_raw1);
a=abs(fft(ptd(2,:).*w1));		// FFT of windowed data

siz_raw2 = size(pt,2)
w2=window('hm',siz_raw2);
b=abs(fft(pt(2,:).*w2));

sa=size(a,2);
sb=size(b,2);

// plot both with normalized (0 -> 1.0) frequency axis
subplot(223)
plot2d([0:sa-1]/sa, a);               // FFT of 'jaggy' signal
// major peaks at .03, .32, .67, .97

subplot(224)
plot2d([0:sb-1]/sb, b, style = 2);    // FFT of smoothed signal
// major peaks at .0017, .017, .98, .998

I expected the narrower peaks.
BUT, shouldn't they be at the same normalized frequency?