# Why does a sine bandwidth decrease with 1/dur, dur beeing the signal duration

4 views (last 30 days)
Jonas on 16 Dec 2021
Edited: David Goodmanson on 19 Dec 2021
Dear community, recently i was interested in the bandwidth of spectra. That's why i did some plots for signals with a single frequency at once but for different amplitude, duration and frequency. I saw, that the amplitude and frequency and amplitude does not influence the bandwidth in this case but signal duration does. can someone tell me why and why it is like a constant divided by the duration (~1/x). The constant changes a bit if a analyze the power spectrum instead of PSD, but the behavior stays the same. the behavior also stays the same if take the way over fft function and a linspaced frequency vector here a sample script; for anyone who is confused about the many loops can just set the ampNr and f0 value to one number only.
close all;
fs=8000;
dur=0.1:0.1:2;
cl=lines(6);
amp=1:6;
tiledlayout('flow');
for ampNr=amp
nexttile();
for f0=100:100:1000
myBW=nan(size(dur));
for durNr=1:numel(dur)
t1=0:1/fs:dur(durNr)-1/fs;
s1=sin(2*pi*f0*t1);
s1=s1+rand(size(s1))-0.5;
[spec,fSpec,tSpec,p]=spectrogram(s1,length(s1),[],[],fs);
[val,~,bw]=findpeaks(abs(spec),fSpec,'MinPeakHeight',0.9*max(p));
[~,idx]=max(val);
bw=bw(idx);
myBW(durNr)=bw;
end
end
plot(dur,myBW,'Color',cl(ampNr,:)); hold on;
xlabel('sine duration (s)');
ylabel('bandwidth (Hz)');
title(['sine amplitude ' num2str(ampNr)])
plot(dur,1.76./dur,'--k');
end
best regards
Jonas

David Goodmanson on 18 Dec 2021
Edited: David Goodmanson on 18 Dec 2021
Hi Jonas,
I believe what you are seeing is just the natural reciprocal relation between width in the time domain and width in the frequency domain of the transformed signal. In physics this is nothing more than the Heisenberg uncertainly principle.
Suppose you have a signal f(t), with a characteristic width (let's say it is determined by the standard deviation) of width t0. Now suppose the same signal is stretched in time by a factor of b. Without getting into details of normalization and so forth, it looks like f(t/b) and its width is b*t0. The transform of the original function is
Int f(t) exp(iwt) dt = g(w)
Suppose it has a width w0. The transform of the stretched function is
Int f(t/b) exp(iwt) dt = Int f(t/b) exp(i(bw)(t/b)) (dt/b) b
and denoting t/b by s,
= Int f(s) exp(i(bw)s) ds b
= g(bw) b
The hanging b is due to not paying attention to normalization and would go away with proper normalization of all this. That doesn't change the fact that the frequency domain function, g(bw) has width w0/b and so is shrunk by the same factor that f(t/b) was expanded by. So the product of widths, width(f)*width(g), is a constant. It's also dimensionless.
As you have alluded to, ploting dur.*myBW gives a nice nearly flat line.
David Goodmanson on 19 Dec 2021
Hi Paul,
You may well be correct. It could boil down to a difference of point of view, though. I took a physics point of view, where scaling arguments apply quite pervasively. In this particular problem, there is an initial idea that the bandwidth is zero. However, some at-the-moment unspecified process has come up with a nonzero bandwidth. With scaling as a general principle and some admitted handwaving, one can argue that no matter what (linear) process was involved, frequency resolution or anything else, the end result will still have to come out width(f)*width(g) = constant. So I think a frequency resolution argument could be tracked back to the scaling law. However, looking at the details of a specific process as you are doing will provide better understanding of what is going on.

Jon on 16 Dec 2021
Edited: Jon on 16 Dec 2021
I don't have enough time at the moment to look at your code in depth, but I'm suspecting that you are experiencing "leakage" effects by not having an integral number of periods of the signal. So the truncation of your signal causes some extra energy outside of the pure sine frequency.
I suggest that you try changing your duration, but always keep the total duration an integral multiple of the sine wave's period and see if the behavior changes.
Jonas on 18 Dec 2021
the use of the function spectrogram may be confusing here, but in this case i choose the length of the analysis window as the length of the whole signal, this way i have one 1 time bin and dont have to bother with creation of the fft frequency vector, normalization or fftshifting

R2021a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!